The method SelectNextControl of the base class control doesn't work with the Krypton Toolkit controls.
I have created a form with a Krypton panel with the dock property to Fill
Then add this code :
- Code: Select all
public partial class Form1
{
public Form1()
{
InitializeComponent();
// Create a textbox
KryptonTextBox ktbTextBox = new KryptonTextBox();
ktbTextBox.Name = "Control1";
ktbTextBox.Text = "";
ktbTextBox.Location = new System.Drawing.Point(3, 20);
ktbTextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
ktbTextBox.TabIndex = 1;
kpPanel.Controls.Add(ktbTextBox);
ktbTextBox = new KryptonTextBox();
ktbTextBox.Name = "Control2";
ktbTextBox.Text = "";
ktbTextBox.Location = new System.Drawing.Point(3, 60);
ktbTextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
ktbTextBox.TabIndex = 2;
kpPanel.Controls.Add(ktbTextBox);
ktbTextBox = new KryptonTextBox();
ktbTextBox.Name = "Control3";
ktbTextBox.Text = "";
ktbTextBox.Location = new System.Drawing.Point(3, 100);
ktbTextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown);
ktbTextBox.TabIndex = 3;
kpPanel.Controls.Add(ktbTextBox);
}
/// <summary>
/// Occurs on control key down
/// </summary>
/// <param name="sender">Event sender</param>
/// <param name="e">Event arguments</param>
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
// If it's the ENTER key
if(e.KeyCode == System.Windows.Forms.Keys.Enter)
{
// Get the current control
KryptonTextBox cControl = ((KryptonTextBox)sender);
// Set focus on the next control, so perform the validating event on the current control
cControl.Parent.SelectNextControl(cControl, true, true, false, false);
}
}
}
The focus must pass to the next control when ENTER is pressed, It doesn't work
If i replace KryptonTextBox by TextBox, it works