PDA

View Full Version : سوال: تبديل دكمه enter به tab



maryam_59m
چهارشنبه 13 خرداد 1388, 15:27 عصر
من مي خوام توي فرم ام ، هر وقت كه دكمهEnter رو زدم اين دكمه كار Tab رو برام انجام بده

debugger
چهارشنبه 13 خرداد 1388, 16:23 عصر
شما مي تونين از كد زير كه يكي از كاربران در اين انجمن نوشته اند بهره بگيريد . كافي هست كد زير را در فرم هايي مي خواهيد اين كار انجام شود كپي كنيد.



protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (msg.Msg == 256 && keyData == System.Windows.Forms.Keys.Enter)
{
// Execute an alternative action: here we tabulate in order to focus on the next control in the formular
if(this.ActiveControl.ToString().Contains("System.Windows.Forms.Button"))
return base.ProcessCmdKey(ref msg, keyData);
else
{
System.Windows.Forms.SendKeys.Send("{TAB}");
// return true to stop any further interpretation of this key action
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}