开发者

C# Datatable column width

开发者 https://www.devze.com 2023-04-06 06:29 出处:网络
Im having a problem with Datatable in C#. I have a Datatable with to columns. I want to manually set the size of the columns, how do I do this?

Im having a problem with Datatable in C#. I have a Datatable with to columns. I want to manually set the size of the columns, how do I do this?

this is the code:

dt = new DataTable();

DataColumn culAvs = new DataColumn("Avskiping", typeof(string));
DataColumn culKota = new DataColumn("Kota", typeof(string));
dt.Columns.Add(culAvs);
dt.Columns.Add(culKota);
dataGrid1.Da开发者_Python百科taSource = dt;


If you're talking about maximal length of data in columns, you might be interested in DataColumn.MaxLength property. But if you're talking about visual width of columns you should use Width property of a DataGrid's column: dataGrid1.Columns[ ... ].Width = ...


The data table does not contain UI related properties, it's a data container. You need to define the column visual properties on the data grid.

0

精彩评论

暂无评论...
验证码 换一张
取 消