DGV和Forms自动调整大小 [英] DGV and Forms Autosize
问题描述
我有一个带有可变行数和可变列大小的DGV。下面是一个文本框。我想做什么:
DGV应该调整到真正使用的空间。表单应调整为用于保存DGV和文本框的大小。可以通过Autosize完成吗?到目前为止,我无法找到如何做到这一点 - 请帮助
wolltiger,
欢迎来到MSDN 论坛,
以了解更多调整大小选项。
我希望这会有所帮助。
祝你好运,
Bob
I have a DGV with variable No. of Rows, and varable colum size. Below that there is a textbox. What I want to do:
The DGV should resize to the space really used. And the Form should resize to the size used to hold the DGV and the Textbox. May this be done by Autosize? Up to noe I could'nt find out how to do this - Pls Help
Hi wolltiger,
Welcome to MSDN Forum,
The AutoSize property enables a control to change its size, if necessary, to attain the value specified by the PreferredSize property. You adjust the sizing behavior for specific controls by setting the AutoSizeMode property. See AutoSize Property Overview to know AutoSize Behavior and Controls That Support the AutoSize Property.
I made a demo show to you.
Form Design:
Code:
private void Form2_Load(object sender, EventArgs e) { this.AutoSize = true; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; panel1.AutoSize = true; panel1.AutoSizeMode = AutoSizeMode.GrowAndShrink; dataGridView1.AutoResizeColumns(); dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; }Show Result:
Refer the Sizing Options in the Windows Forms DataGridView Control to know more resize option.
I hope this can be helpful.
Best regards,
Bob
这篇关于DGV和Forms自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!