1. the first blank column is not displayed.
The rowheadervisible attribute is set to false.
2. Click cell to select the entire row
Rowselectinmodel attribute settings
You can also use the cellclick event.
// Select the entire row
Private void maid cellclick (Object sender, maid E)
{
// E. rowindex>-1 otherwise, clicking the header is also called a column.
If (maid. Count> 0 & E. rowindex>-1)
{
// MessageBox. Show (E. rowindex. tostring ());
Datagridview1.rows [E. rowindex]. Selected = true;
}
}
3. Add button image button column events
To display text on the button, set the text attribute. There is no value by default. However, it is not clear why the datapropertyname field is not displayed. Therefore, the values of recognition records such as ID must be placed in other columns. // Button event
Private void maid (Object sender, maid E)
{
If (E. columnindex = 1)
{
MessageBox. Show (maid [E. rowindex]. cells [1]. value. tostring ());
}
}
4. Add an external button to obtain the selected private void button#click (Object sender, eventargs E)
{
If (maid. Count> 0)
{
MessageBox. Show (maid [0]. cells [1]. value. tostring ());
}
}
5. other settings.
Whether multiple rows can be selected: multiselect.
Fields in the data table are not automatically bound.
Extend the width of the last column to the upper-level width: Set autosizemodel to fill