When the cell content needs to be formatted for display.
For example:
Code
/// <Summary>
///Cell display format event
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private VoidMaid (ObjectSender,
Datagridviewcellformattingeventargs E)
{
//Display the number * in the 4th column. The number * is the same as the actual data length.
If(E. columnindex =3)
{
If(E. value! =Null& Amp; E. value. tostring (). Length & gt;0)
{
E. value =New String('*', E. value. tostring (). Length );
}
}
}
The datagridview. editingcontrolshowing event occurs when the control used to edit cells is displayed.
/// <Summary>
/// Edit a cell control event
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private Void Datagridview1_editingcontrolshowing ( Object Sender, datagridvieweditingcontrolshowingeventargs E)
{
// when editing the 4th column, the 4th column is displayed as the * number
textbox T = E. control as textbox;
If (T! = null )
{
If(This. Maid. columnindex =3)
T. passwordchar ='*';
Else
T. passwordchar =New Char();
}
}
Datagridview add any controls
Void Datagridview2_editingcontrolshowing ( Object Sender, datagridvieweditingcontrolshowingeventargs E)
{
If (E. Control Is Datagridviewtextboxeditingcontrol)
{
Textbox = (textbox) E. Control;
// Panel P = (panel) textbox. parent; // Finding the current parent control is actually a panel. You can clear the control in this panel, and then you can add any control to the Panel and layout it at will.
Panel P = (panel) E. Control. parent;
P. Controls. Clear ();
BTN. width = 38 ;
BTN. Text = textbox. text;
BTN. Click + = New Eventhandler (btn_click );
P. Controls. Add (BTN );
}
}
Add controls using a container (panel.