1) Hide rows and columns
[VB. NET]
'Hide the first column of maid
DataGridView1.Columns (0). Visible = False
'Hide the first line of maid
DataGridView1.Rows (0). Visible = False
[C #]
// Hide the first column of DataGridView1
DataGridView1.Columns [0]. Visible = false;
// Hide the first row of DataGridView1
DataGridView1.Rows [0]. Visible = false;
2) Hide the row header and column header
[VB. NET]
'Column header hiding
Maid = False
'Line header hiding
Maid = False
[C #]
// Hide the column header
Maid = false;
// Hide the row Header
Maid = false;
3) Delete rows and columns
[VB. NET]
'Delete a column named "Column1"
DataGridView1.Columns. Remove ("Column1 ")
'Delete the first column
DataGridView1.Columns. RemoveAt (0)
'Delete the first line
DataGridView1.Rows. RemoveAt (0)
[C #]
'Delete a column named "Column1"
DataGridView1.Columns. Remove ("Column1 ");
'Delete the first column
DataGridView1.Columns. RemoveAt (0 );
'Delete the first line
DataGridView1.Rows. RemoveAt (0 );
4) Delete the selected row
[VB. NET]
For Each r As DataGridViewRow In DataGridView1.SelectedRows
If Not r. IsNewRow Then
DataGridView1.Rows. Remove (r)
End If
Next
[C #]
Foreach (DataGridViewRow r in DataGridView1.SelectedRows)
{
If (! R. IsNewRow)
{
DataGridView1.Rows. Remove (r );
}
}