简体   繁体   中英

How to autosize datagridview rows to get rid of blank gray areas

Hello I have a vbnet windows forms application and I'm looking for a simple way of deleting the blank areas of a datagridview. I know there is a simple way of doing this for columns using the

DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

It seems sort of strange to me that there isn't a similar way of dong this for the rows. Does anyone know of a simple way of fixing this issue? I greatly appreciate any help or suggestions you may offer.

在此处输入图片说明

If you dont want empty rows in your grid, do not load them in the grid.

Grids are usually filled by setting its' DataSource property. This may be anything that implements IList, and a few other things like a DataTable/DataSet. If you dont want them in the grid, dont put them in the object that you used as your DataSource.

If you used some type of list the implements INotifyCollectionChanged, like an ObservableCollection or BindingSource, you can Remove the items after they are added.

要摆脱该“空白”区域,您需要调整网格的大小。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM