HowTo : How can I make command's line textbox to accept spacebar as enter
Article | 60001387 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 5/4/2011 |
Submitted by | Peter Chanios |
Keywords | |
Subject
How can I make command's line textbox to accept spacebar as enter
Summary
I want to make the commandline to behave the same when I press enter and when I press spacebar.
Solution
You should use the Command's line userText box event KeyDown and send an enter message to it when the space is pressed like in the code below :
void UserText_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
VectorDraw.WinMessages.MessageManager.MSG m = new VectorDraw.WinMessages.MessageManager.MSG();
m.hwnd = vdFramedControl1.CommandLine.UserText.Handle;
m.lParam = IntPtr.Zero;
m.message = (int)VectorDraw.WinMessages.MessageManager.Messages.WM_KEYDOWN;
m.wParam = (IntPtr)Keys.Enter;
VectorDraw.WinMessages.MessageManager.TranslateMessage(ref m);
VectorDraw.WinMessages.MessageManager.DispatchMessage(ref m);
}
}
private void Form1_Load(object sender, EventArgs e)
{
vdFramedControl1.CommandLine.UserText.KeyDown += new KeyEventHandler(UserText_KeyDown);
}