UserControl 放在表单上时会膨胀吗?
编辑> 已解决:事实证明,我已将所有 UI 元素的字体属性设置为 14pt Arial,但没有将用户控件本身设置为,因此当它在表单上绘制它时,它会调整其全部大小。 将用户控件的字体大小更改为 14pt Arial,然后重新定位/调整所有内容的大小即可修复此问题。
我开始为我正在制作的应用程序开发用户界面。 该应用程序有一个 devexpress 选项卡控件,最初我只是将所有控件放在那里以查看它的外观并解决任何布局问题。 好吧,我决定提取每个选项卡页的所有 ui 元素,并将它们放入 UserControl 中,并让该 UserControl 填充选项卡页。
问题是,在用户控件中时它看起来完全正常(即与以前相同),但是当我将其带到选项卡页时,所有 ui 元素都很大(大小大约是两倍,但不完全是两倍)。
这里有一些图片可以向您展示我的意思。
编辑> 注意:这是一个 winforms 应用程序。
用户控制:
编辑> 图像已删除
表格:
编辑> 图像已删除
事实证明,对象正在调整大小。 我在 usercontrol.load 事件之后检查了 ui 元素的 .Size 属性,它们比预期的大得多。 如果有我想要的锚定,所有锚定在左上角并且根本没有锚定,就会发生这种情况。
EDIT > SOLVED: It turns out that I had set all of the UI elements' font properties to be 14pt Arial, but not the usercontrol itself, so when it was drawing it on the form, it was resizing it all. Changing the usercontrol's font size to 14pt Arial, and then repositioning/resizing everything fixed it.
I started working on the UI for an app I'm making. The app has a devexpress tab control, and initially I was just placing all of my controls in there to see what it'd look like and to work out any layout issues. Well, I decide to pull out all of the ui elements for each tabpage and toss them into a UserControl and to have that UserControl fill the tab page.
The problem is that it looks perfectly normal (ie. the same as before) when in the usercontrol but when I bring that over to the tab page, all of the ui elements are HUGE (about double in size, but not exactly double).
Here's some images to show you what I mean.
Edit> Note: This is a winforms app.
UserControl:
edit > images removed
Form:
edit > images removed
It turns out that the objects are being resized. I checked the .Size property of the ui elements after the usercontrol.load event and they are much larger than they are supposed to be. This happens if there is the anchoring as I'd like it, all top-left anchored and no anchoring at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UserControl 的 AutoScaleMode 应为“None”...
The AutoScaleMode of the UserControl should be at "None"...
没有看到代码很难说...
[编辑]
好吧,如果你没有代码,那么我只有一个想法。 用户控件内的控件具有调整为父控件大小的锚点。 父控件可能比预期大,从而使所有锚点随父控件进行调整。 这会让它们看起来太大了。 这是我唯一的想法...
[/编辑]
Hard to say without seeing code...
[edit]
Well if you have no code then I only have one idea. The controls inside your user control have anchors that are being adjusted to the size of the parent control. The parent control could be larger than expected making all the anchors adjust with the parent. This would then make them all appear too big. This is my only idea...
[/edit]