CPK_2011
CPK_2011

Reputation: 1150

DataGridView To show cell content completely

I am filling the datagridview with data and the data is not completely visible in each cell. How can I show all content which even has Enter Keys in it.

Upvotes: 3

Views: 8311

Answers (2)

CPK_2011
CPK_2011

Reputation: 1150

This will diplay the cell content completely.

DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; 

Upvotes: 3

Vignesh Vino
Vignesh Vino

Reputation: 1238

Continuing from your comment above Try some like this

With DataGridView1.Columns("Message")
                .Width = 150
                .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
                .DefaultCellStyle.WrapMode = DataGridViewTriState.True
            End With

EDIT:

// Resize the master DataGridView columns to fit the newly loaded data.
    masterDataGridView.AutoResizeColumns();
// Configure the details DataGridView so that its columns automatically 
// adjust their widths when the data changes.


 private void SizeAllColumns(Object sender, EventArgs e)
{
    dataGridView1.AutoResizeColumns(
        DataGridViewAutoSizeColumnsMode.AllCells); 
   dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.Fill);

}

Upvotes: 2

Related Questions