Reputation: 1303
I searched for Autosizing of cell but found Auto-size row and column how can I make particular cell autosize (in terms of height since column width will be fixed)according to data size of that particular cell? can it be done using some property of datagridview?
Upvotes: 1
Views: 5921
Reputation: 1303
This line of code make Cell Auto-size Vertically
depending on the data loaded
dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
Upvotes: 3
Reputation: 8902
You can handle it through properties of DataGridView, Set the following properties. Setting follwing properties will allow the cell to expand (Vertically or horizontally) to show the full content without any truncation. These cell size expansion will result in either row or column size change where the cell exisit.
AutoSizeRowsMode
= AllCellsAutoSizeColumnsMode
= DisplayedCellsUpvotes: 0
Reputation: 2523
Use this code. It can help you
dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
where 0 is column index
Upvotes: 0