开发者

How to increase the width of columns of a DataGrid in VB

开发者 https://www.devze.com 2023-04-01 21:12 出处:网络
I am using DataGrid control in VB. I have created a DataTable at runtime and added 5 columns in this Datatable.

I am using DataGrid control in VB. I have created a DataTable at runtime and added 5 columns in this Datatable. I binded the data table with DataGrid control.

Width of DataGrid is 880. The default width of 5 columns of data table in DataGrid is 100. So for 5 columns width used = 500. So an empty space of 380 left at the right hand cornor of DataG开发者_JAVA技巧rid. I want to fill this empty space with these 5 columns. I want to increase the width of columns so that it fully covered in DataGrid.


Take a look at the DataGrid.PreferredColumnWidth Property property.

DataGrid1.PreferredColumnWidth = 176

In this case, 176 is 880 / 5.

This value may get overriden if the data in a column is more than 176, however.

You may also want to look at:

DataGridTableStyle Class

DataGridColumnStyle Class

0

精彩评论

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