/// <Summary>
/// Method related to Form Control
/// </Summary>
Public class ControlTools
{
Private Form frm;
Public ControlTools (Form frm)
{
This. frm = frm;
}
/// <Summary>
/// Press enter of all child controls on the form to set it to a Tab
/// </Summary>
Public void EnterToTab ()
{
Frm. KeyPreview = true;
Frm. KeyPress + = new KeyPressEventHandler (frm_KeyPress );
}
/// <Summary>
/// Register the KeyPress event of the form
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void frm_KeyPress (object sender, KeyPressEventArgs e)
{
If (e. KeyChar = (char) Keys. Enter)
{
Frm. SelectNextControl (frm. ActiveControl, true, true );
}
}
/// <Summary>
/// Set the carriage return of all the child controls (TextBox ComboBox) of a control to a Tab
/// </Summary>
/// <Param name = "groupControl"> container control </param>
Public void EnterToTab (Control groupControl)
{
Foreach (Control control in groupControl. Controls)
{
If (control is TextBox | control is ComboBox)
Control. KeyPress + = new KeyPressEventHandler (control_KeyPress );
}
}
/// <Summary>
/// Register the KeyPress event of the control
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Private void control_KeyPress (object sender, KeyPressEventArgs e)
{
If (e. KeyChar = 13)
{
SendKeys. Send ("{Tab }");
E. Handled = false;
}
}
}