1.DataGridView controls
Show data table
(1) 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 ();
(2) Front desk:
Small triangle arrow, cancel editable, add, delete function;
Columns The collection property, add the column
Set the displayed text in HeaderText
DataPropertyName Setting the field name or database column name of the binding
SelectionMode--Set selection method, Fullrowselect can only select BOC
MultiSelect-whether multiple lines of content can be selected
(3) Value:
Remove the value of the selected cell:
All selected cells are in the Datagridview1.selectedcells
if (DataGridView1.SelectedCells.Count > 0)
{
MessageBox.Show (datagridview1.selectedcells[0]. Value.tostring ());
}
Remove the selected line contents:
if (DataGridView1.SelectedRows.Count > 0)
{
MessageBox.Show (datagridview1.selectedrows[0]. Cells[0]. ToString ());
}
gets the object used to populate the row bindings:
//Row Object Usage properties: Databounditem
Student SSS = datagridview1.selectedrows[0]. Databounditem as student;
2.Dock Properties
Top: Up, height constant, left and right (width) stretch
Bottom: Bottom, height constant, left and right stretch
Fill: Fills the entire area
Left: Right, width unchanged, stretched up and down
Right: Left, width unchanged, stretched up and down
WinForm DataGridView controls, duck layouts