简体   繁体   English

设计器中的按钮大小不同于Debug VB.NET Visual Studio中的按钮大小

[英]Button Sizes in Designer Different than in Debug VB.NET Visual Studio

I have a VB.NET project which has a ToolStrip containing multiple ToolStripButtons . 我有有一个VB.NET项目ToolStrip包含多个ToolStripButtons

I have just recently increased the width of these buttons by ~30% to account for an increase in their text sizes. 我最近刚刚将这些按钮的宽度增加了约30%,以解决它们的文本大小增加的问题。 In the designer this width change has been reflected and looks good. 在设计师中,这种宽度变化已经得到体现并且看起来不错。

The issue is when I run the application in debug mode the changes have not been reflected. 问题是,当我在调试模式下运行应用程序时,更改未反映出来。 The text is changed but overflows because the buttons are not the correct width. 文本已更改,但由于按钮的宽度不正确而溢出。

Looking through the Designer.vb code the correct System.Drawing.Size is specified and AutoSize is set to false for each button. 浏览Designer.vb代码时,将为每个按钮指定正确的System.Drawing.Size并将AutoSize设置为false。

Does anyone have any ideas as to why the width of these buttons will not increase? 有谁知道为什么这些按钮的宽度不会增加?

Most of the time, when this issue happens, there are 2 options: 在大多数情况下,发生此问题时,有两种选择:

  1. It is either a glitch (which is a rare event) 这是一个小故障(这是罕见的事件)
  2. You have other code that overrides the one you want. 您还有其他代码可以覆盖所需的代码。

If it is a glitch, restart your project or try it on another computer. 如果出现故障,请重新启动项目或在另一台计算机上尝试。 The main thing is if it is not. 最主要的是,如果不是。 When I encounter this type of problem, I delete the objects in this case your entire ToolStrip . 遇到此类问题时,在这种情况下,我将删除整个ToolStrip的对象。 What I do then is remove any code related to it in any way. 然后,我要做的是以任何方式删除与其相关的任何代码。 After that, insert another ToolStrip and write the code you want. 之后,插入另一个ToolStrip并编写所需的代码。 Most of the time this works with me. 在大多数情况下,这与我合作。 If it doesn't, you have one more option: 如果没有,您还有一个选择:

The code you have could be something similar to this: (It happened to me once after lots of Find and Replace) 您拥有的代码可能类似于以下内容:(在进行大量“查找和替换”之后,它发生在我身上)

 Dim picBig as boolean
 Dim picSmall as boolean
 'Some code to change a picturebox's size. There was an outline label that detects if it is over limit

 If Picturebox4.IntersectsWith(Outline.Bounds) Then
    picBig = True
 'Code for a message box
 'Code to make the picturebox smaller.
 End If
 If Picturebox4.IntersectsWith(Outline.Bounds) Then
   picSmall = True
  '... and so on as above.
 End If

As you can see, my program doesn't make sense. 如您所见,我的程序没有意义。 The second was meant to be sOutline.Bounds , but I made this mistake after repeatedly removing, copying, and pasting chunks of code here and there. 第二个应该是sOutline.Bounds ,但是我在sOutline.Bounds反复删除,复制和粘贴代码块后犯了这个错误。 Try looking for some of those, because otherwise the debugger does it exaclty what is in your code. 尝试查找其中的一些内容,因为否则调试器会检查代码中的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM