DataGridView - 如何设置列宽? [英] DataGridView - how to set column width?
本文介绍了DataGridView - 如何设置列宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个WinForms应用程序,具有 DataGridView
控件。我的控制有五个
列(例如名称,地址,电话等)。
I have a WinForms application with DataGridView
control. My control has five
columns (say "Name", "Address", "Phone" etc)
我对默认列宽不满意。我想对柱子的外观有更多的控制。我想要
是能够执行以下操作之一:
I am not happy with default column width. I want to have more control over column appearance. What I want is to be able to do one of the following:
- 设置每列的宽度百分比
- 设置每列的宽度(以像素为单位)
- 使用其他最佳实践方法(使宽度适合文本等)
请建议 - 要使用的属性和方式。
Please suggest - which property to use and how.
推荐答案
你可以使用DataGridViewColumn.Width属性来执行:
You can use the DataGridViewColumn.Width property to do it:
DataGridViewColumn column = dataGridView.Columns[0];
column.Width = 60;
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.width.aspx
这篇关于DataGridView - 如何设置列宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文