如何在数据网格视图中制作多行单元格
问题描述:
我可以在Datagridview中创建多行单元格吗?并非所有单元格都选择了我想要制作多行的单元格。以及如何增加datagridiew行的高度
Can i make multi line cell in Datagridview.?? Not all cell only selected cells i want to make multi line. and how can increase the height of datagridiew rows
答
首先通过设置默认样式使您感兴趣的单元格可以包装...
Firstly make the cells that you are interested in wrappable by setting the default style ...
dataGridView1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
注意我这里只选择了第一列[0]。如果你想要所有单元格换行,那么使用
Note I've chosen only the first column here [0]. If you wanted all cells to wrap then use
dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
自动增加所有行的高度...
To increase the height of all of the rows automatically ...
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
或者如果你想专门针对特定行,那么它就是
or if you want to specifically target specific rows then it's
dataGridView1.AutoResizeRow(RowNumber, DataGridViewAutoSizeRowMode.AllCells);
其中 RowNumber
是一个整数值。我的建议是让控件通过
where RowNumber
is some integer value. My advice would be to let the control do the resizing though