简体   繁体   English

如何设置.NET Win App控件的大小属性在不同系统上具有相同的外观?

[英]how to set .NET win app controls size properties to have same looking on different systems?

hi i have developed a windows forms application and I deployed it and I installed It on another system with different screen reselution and some of my controls don't look as they did on my own system for example I have lables in a groupbox and in the target machin they have exceeded the bounderies of the group box ! 嗨,我已经开发了一个Windows窗体应用程序,并部署了它,并将其安装在另一个具有不同屏幕重设功能的系统上,并且某些控件看上去不像在我自己​​的系统上那样,例如,我在组框和目标机器他们已经超出了分组框的边界! I want to know how should I exactly set different size properties of different controls to have same looking on different systems with different reselutions and different screen inches ?! 我想知道我应该如何正确设置不同控件的不同大小属性,以使它们在具有不同分辨率和屏幕英寸的不同系统上具有相同的外观?

thanks in advance for your reply 预先感谢您的答复

I will assume you are using Windows Presentation Foundation (WPF); 我假设您使用的是Windows Presentation Foundation(WPF); if so, you will need to set a Grid inside of your GroupBox control. 如果是这样,则需要在GroupBox控件中设置一个Grid。 If you are used to HTML you can think of the Grid as being something like a table. 如果您习惯使用HTML,则可以认为Grid就像表格一样。 Then arrainge your Labels or other controls within the Grid. 然后在网格内设置标签或其他控件。 Below is an example and be sure to note the Margin tags. 下面是一个示例,请务必注意“保证金”标签。 They are what positions the control within the Grid. 它们是控件在网格中的位置。

<GroupBox Header="groupBox1" Height="135" HorizontalAlignment="Left" Margin="12,78,0,0" Name="groupBox1" VerticalAlignment="Top" Width="287">
    <Grid>
        <Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="45,28,0,0" Name="label1" VerticalAlignment="Top" />
    </Grid>
</GroupBox>

To do the same in Windows Forms you would need to manually add the control to the GroupBox. 若要在Windows窗体中执行相同的操作,则需要将控件手动添加到GroupBox。

gbCtrl = new GroupBox();
gbCtrl.Left   = 20; // <- These are relative to the main form.
gbCtrl.Top    = 20;
gbCtrl.Width  = 120;
gbCtrl.Height = 60;
gbCtrl.Text = "Sample GroupBox";

Button btnSample = new Button();
btnSample .Left = 22; // <- These are relative to the groupbox
btnSample .Top  = 24; // 
gbCtrl.Controls.Add(btnSample); // <- Add the button to the groupbox

Controls.Add(gbCtrl); // <- Add the groupbox to the main form.

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

相关问题 MonthCalendar控件在不同的系统上改变大小,如何适应表格的适应性? - MonthCalendar controls changes size on different systems, how to adapt form to accomodate? 如何确保设置Asp .net控件的属性 - How to ensure that properties for Asp .net controls are set 如何使用不同的控件组绘制相同区域? - How do I paint the same area with different set of controls? ConfigurationManager在不同系统上寻找不同文件 - ConfigurationManager looking for different files on different systems 如何在Windows自定义控件中设置动态属性 - How to set dynamic properties in Windows Custom Controls 如何禁用设置控件属性的可能性? - How to disable the possibility to set Properties for Controls? 如何在继承的类中设置相同名称但不同类型的属性 - How to set properties of same name but different types in inherited classes 如何在asp.net中设置Reportviewer控件报表服务器URL和报表路径属性 - how to set Reportviewer controls report server Url and report path properties in asp.net 如何在同一表格上同时为两个不同的控件设置两个不同的文化? - How to set two different Cultures for two different Controls on a single Form at the same time? 验证绑定到同一对象的不同属性的控件会重置对象值 - Validating controls bound to different properties of the same object resets objectvalues
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM