-1

I've tried looking many places for an answer to an issue I'm having and so far I've found nothing.

What I currently have is a c# windows form with user controls inside it. Some user controls have other controls inside them. What happens when I change the text in a textbox, is its parent windows will no longer resize like they should when changing the window size. i.e. A horizontal scrollbar will appear even though horizontal scrollbars are disabled in that specific window. Its almost as if changing the text changes the parent window's styling.

In case this is too vague, I have a textbox inside a panel with a docking property set to fill. The panel has a padding of 10 in order to allow the textbox to have some white space for aesthetic purposes. This control resides within a parent control (we'll call it parent 1), which in turn resides within another control as well (we'll call it parent 2). So when I change the textbox's text (at all, even adding a space), will then make parent 2 have a horizontal scrollbar flicker and sometimes even remain when resizing the form window manually.

4

2 回答 2

0

我发现了我的问题!当使用 autoScrollBars 和双缓冲时,它会导致水平滚动条在调整窗口大小时显示它不应该显示的时间(至少在我的情况下)。答案很简单,忘记autoScrollBars,实现我自己的垂直滚动条!

实际上,我正在将一些代码张贴在这里供大家查看,但是在查看它时,我决定忘记自动滚动,并且瞧瞧它起作用了!

我其实很好奇为什么会这样。我的朋友听说 .net 的 autoScroll 存在一些问题,但我认为不会到这种程度。

于 2012-10-10T21:49:58.993 回答
0

您应该确保不仅TextBoxinUserControl停靠以填充,而且用户控件本身及其父级(及其父级)都正确停靠或设置了锚点,以便它们与表单一起调整大小。

当用户输入字符时,您是否执行任何特殊代码?(KeyPressed事件等)。如果是,您应该尝试暂时禁用这些事件,看看它们是否会导致问题。

如果您发布代码示例,它会更容易提供帮助。没有这个,我们只能猜测,就像我试过的那样......

于 2012-10-02T22:34:20.477 回答