DataGridView:
Displaying data tables
Background Data binding:
list<xxx> list = new list<xxx> ();
Datagridview1.datasource = list;
Setting does not automatically generate columns, this property is not in the properties panel
Datagridview1.autogeneratecolumns = false;
Cancel load Default Check first row
Datagridview1.clearselection ();
Front desk:
Small triangle arrow, cancel editable, add, delete function;
- Columns collection properties, adding columns
- Set the text displayed in HeaderText
- DataPropertyName sets the field name or database column name of the binding
- SelectionMode--Set the selection mode, Fullrowselect can only select rows
- MultiSelect--Can I select multiple lines of content
Take value:
Remove the value of the selected cell:
All selected cells are placed in the Datagridview1.selectedcells
if (DataGridView1.SelectedCells.Count > 0)
{
MessageBox.Show (Datagridview1.selectedcells[0]. Value.tostring ());
}
To remove the selected row contents:
if (DataGridView1.SelectedRows.Count > 0)
{
MessageBox.Show (datagridview1.selectedrows[0). Cells[0]. ToString ());
}
Gets the object used to populate the row bindings:
Row objects using attributes: Databounditem
Student SSS = Datagridview1.selectedrows[0]. Databounditem as student;
Dock property:
1.Top: Top, height unchanged, left/right (width) stretch
2.Bottom: Down, height unchanged, stretching left and right
3.Fill: Fill the entire area
4.Left: Left, width unchanged, up and down stretch
5.Right: Right, width unchanged, stretching up and down
Through this article, I hope to help you learn this part of knowledge, thank you all for the support of this site!