简体   繁体   English

如何通过C#将控件大小设置为“自动”?

[英]How can I set as “auto” a control size by C#?

**I want to set as "" the size (width and heigth) of an element such as a TextBox" by C# but I can't. **我想通过C#将诸如TextBox之类的元素的大小(宽度和高度)设置为“”,但我不能。

I've to try anything as the following but it doesn't work: 我必须尝试以下任何方法,但无法正常工作:

TextBox1.Width = double.NaN;

I want to know hoy can I do that? 我想知道我可以这样做吗?

as you can see here: WebControl.Width Property the property is of type Unit, so you can do this for example: 如您在此处看到的: WebControl.Width属性,该属性的类型为Unit,因此您可以例如执行以下操作:

TextBox1.Width = Unit.Percentage(100);

look at the methods and constructor of the Unit Structure for more examples. 查看单元结构的方法和构造函数以获取更多示例。

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

相关问题 C#:如何让用户控件正确自动调整大小 - C#: How to get a user control to properly auto size itself 如何设置最小控制台大小 C#? - How can I set a minimum console size C#? C#:一个在运行时根据控件大小自动调整字体的函数? - C#: A function that will auto adjust fonts base on the control size at runtime? Visual C#,如何使用控件设置SetItemChecked属性? - Visual C#, how can I set SetItemChecked property using Control? C#:如何将Memory stream设置为asp.net图像控件的source属性? - C# :How can i set Memory stream as the asp.net image control's source property? 如何在C#图表控件中为不同系列设置不同的比例? - How can I set different scales for different series in C# chart control? 如何设置Socket UDP下面的缓冲区大小? C# - How can I set the buffer size for the underneath Socket UDP? C# 如何在c#中将defaulty的默认值设置为propertyygrid的大小类型属性? - How can I set default value to size type property of propertyygrid in c#? 如何以编程方式(C#)为Excel单元格设置精确大小(以厘米为单位)? - How can I set an exact size (in centimeters) for an Excel cell programatically (C#)? 如何在 UWP C# 中设置图片和 PDF 大小 - How can set Image and PDF size in UWP C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM