WinForm development (5) - DataGridView control (3) - DataGridView control operation

First, the user is prohibited to change the DataGridView column width, row height, column head height

1.// ban users to change the column width of all columns DataGridView1   

DataGridView1.AllowUserToResizeColumns = false;   

 

Line-height 2.// prevent users from changing DataGridView1 all lines   

dataGridView1.AllowUserToResizeRows = false;   

 

3.// prevent users from changing the height of the column headers   

dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;  

Second, clear the table

1. Clear all columns in the table:

dataGridView1.Columns.Clear();

 

2, empty the table all the rows:

dataGridView1.Rows.Clear();

Third, remove the first column of the table

before fixing:

RowHeadersVisible of the property value to false DataGridView on it.

Modified:

Guess you like

Origin www.cnblogs.com/Teacher-Lu/p/11672866.html