浆纱问题,同时增加了.net用户控件到的TabPage [英] Sizing issues while adding a .Net UserControl to a TabPage

查看:143
本文介绍了浆纱问题,同时增加了.net用户控件到的TabPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复杂的Windows窗体GUI程序,有很多自动化控制的产生和操纵。有一件事,我需要能够做的就是添加一个自定义的用户控件到新instatiated TabPage的。但是,当我的code做到这一点,我得到自动调整大小事件,导致格式化拿到丑陋。如果没有详细说明所有的不同的容器可能可以参与的,基本的问题是这样的:

I have a complex Windows Forms GUI program that has a lot of automated control generation and manipulation. One thing that I need to be able to do is add a custom UserControl to a newly instatiated TabPage. However, when my code does this I get automatic resizing events that cause the formatting to get ugly. Without detailing all of the different Containers that could possibly be involved, the basic issue is this:

在某一点在code我创建了一个新的标签页:

At a certain point in the code I create a new tab page:

TabPage tempTabPage = new TabPage("A New Tab Page");

然后,我将它设置为我想让它保持一定的规模:

Then I set it to a certain size that I want it to maintain:

tempTabPage.Width = 1008;
tempTabPage.Height = 621;

然后,我把它添加到TabControl的:

Then I add it to a TabControl:

tabControl.TabPages.Add(tempTabPage);

然后,我创造,我希望出现在新添加的TabPage的用户控件:

Then I create a user control that I want to appear in the newly added TabPage:

CustomView customView = new CustomView("A new custom control");

下面是问题的原因。在这一点上无论是tempTabPage和customView大小都一样,没有填充或保证金,他们是我想他们是对的大小。我现在尝试这个新的自定义用户控件添加到标签页是这样的:

Here is where the problem comes in. At this point both the tempTabPage and the customView are the same size with no padding or margin and they are the size I want them to be. I now try to add this new custom UserControl to the tab page like this:

tempTabPage.Controls.Add(customView);

在使这个叫customView以及其子控件得到调整大小要大,所以customView的部分被隐藏了。

When making this call the customView and it's children controls get resized to be larger and so parts of the customView are hidden.

谁能给我任何方向上寻找什么,或者什么可能会造成这种问题?

Can anyone give me any direction on what to look for or what could be causing this kind of issue?

由于时间提前。

推荐答案

用户控件的AutoScaleMode属性应该设置为无。

The UserControl's "AutoScaleMode" property should be set to "None".

这篇关于浆纱问题,同时增加了.net用户控件到的TabPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆