.NET版本:VS2008
根据DataGridView控件的AutoSizeMode属性实现最后一列的宽度自适应(根据表格的宽度而非内容的长度)
DataGridView1.Columns(DataGridView1.ColumnCount - 1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
详细参数列表如下:(参考MSDN)
成员名称 |
说明 |
AllCells |
列宽调整到适合列中所有单元格(包括标头单元格)的内容。 |
AllCellsExceptHeader |
列宽调整到适合列中除标头单元格以外所有单元格的内容。 |
DisplayedCells |
列宽调整到适合位于屏幕上当前显示的行中的列的所有单元格(包括标头单元格)的内容。 |
DisplayedCellsExcept |