C#: multiline text in DataGridView control

2019-01-04 13:49发布

Is it possible for the DataGridView control to display multiline text in a cell?

I am using Visual Studio 2005 and C#.

7条回答
地球回转人心会变
2楼-- · 2019-01-04 14:25
dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgv.Columns[1].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
查看更多
Bombasti
3楼-- · 2019-01-04 14:25

If you want to active the multiline text in DataGridView control then WrapMode should be true

enter image description here

查看更多
干净又极端
4楼-- · 2019-01-04 14:28
dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgv.Columns[1].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
查看更多
甜甜的少女心
5楼-- · 2019-01-04 14:32

enter image description here

You can change open datagridview property directly

查看更多
做个烂人
6楼-- · 2019-01-04 14:33
1- Datagridview > properties > DataGridViewCellStyle > WrapMode=True
2 -Datagridview > properties > DataGridViewCellStyle > AutoRowSizeMode=AllCells
3- Datagridview > properties > Cloumn >(cloumn selected which you want to multiline)
      DefaultCellStyle > Alingment=NotSet and WrapMode=NotSet
查看更多
做自己的国王
7楼-- · 2019-01-04 14:37

In my case, I got it to work this way (in addition to setting both AutoSizeRowsMode to AllCells and AutoSizeColumnsMode to AllCells):

dgvTwinReverb.Columns[PEANUT_GALLERY_COLUMN].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dgvTwinReverb.Columns[PEANUT_GALLERY_COLUMN].MinimumWidth = PEANUT_GALLERY_COLUMN_DESIRED_WIDTH;
查看更多
登录 后发表回答