使用户控件在选项卡控件中可调整大小
我无法弄清楚如何让我的用户控件对表单的调整大小事件做出反应。
用户控件存在于我的主窗体的选项卡控件中。
用户控件锚定到选项卡控件的所有侧面还是选项卡页?
选项卡控件固定在窗体的所有侧面。
当我调整主窗体的大小时,选项卡控件会正确调整大小,但用户控件不会。
[摘要]
数据框用户控件
- 带有按钮和文本框的用户控件。
- 文本框的侧面锚定到用户控件。
主窗体
- 有一个固定到表单所有侧面的选项卡控件。
- 选项卡控件有我的 DataBoxUserControl,它的侧面锚定到选项卡控件。
调整 MainForm 的大小会调整选项卡控件的大小,但不会调整用户控件的大小。
[我还尝试过什么]
1. 我尝试在每个选项卡页中放置一个面板控件并锚定该面板。 然后我将用户控件放置在面板中并将其锚定。 要么我做错了,但这也不起作用。
2. 我在某处读到尝试将主窗体的调整大小事件注册到用户控件。 但我不太明白这一点,而且我似乎找不到在哪里再次看到过这一点。
我正在使用 c# 和 .net 3.5
I am unable to figure out how to make my user control react to the resize event of a form.
The usercontrol(s) exist in a tab control of my main form.
The usercontrol(s) are anchored to all sides of the tab control or is it tab page?
The tab control is anchored to all sides of the form.
When I resize my main form the tab control resizes correctly but the usercontrol does not.
[SUMMARY]
DataBoxUserControl
- A user control with a button and a textbox.
- The textbox has it's sides anchored to the usercontrol.
MainForm
- Has a tabcontrol that is anchored to all sides of the form.
- The tab controls have my DataBoxUserControl which has it's sides anchored to the tab control.
Resizing the MainForm resizes the tab control but not the user control.
[WHAT ELSE HAVE I TRIED]
1. I've tried placing a panel control in each tab page and anchoring the panel. Then I placed the user control in the panel and anchor it. Either I'm doing it wrong but that didn't work either.
2. I read somewhere to try register the resize event of the main form to the user control. But I don't really understand that and I can't seem to find where I saw that again.
I am using c# and .net 3.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您需要将用户控件的停靠属性设置为“填充”以使其自动调整为某个区域的大小。
I believe you need to set the dock property of the user control to "fill" to have it auto resize to an area.