I have a devexpress textbox in a usercontrol in winforms application. The problem is, when the usercontrol is loaded, and user clicks on the devexpress textbox, which in turn calls for OSK keyboard, loses focus from the textbox.
The user cannot directly start typing on OSK. Instead he needs to click on the textbox to gain focus back again and start typing.
Please suggest if there is any solution for this.
What I have found through debugging is, when I place a breakpoint on the set focus code, the focus is assigned to the textbox. But when I try to run it in a single go, it doesnot set the focus.
private void OnMouseClickUserControl(object sender, MouseEventArgs e)
{
// verify if the button is displayed
if (!this.ShowButton)
{
this.OnEnterUserControl(this, e);
}
}
private void OnEnterUserControl(object sender, EventArgs e)
{
// verify if button is displayed
if (!this.ShowButton)
{
// set the input scope
this.SetInputScope();
// show the keyboard
TabTip.OpenTabTip();
// focus the helper textbox
//this.tbxText.Focus();
this.tbxText.SelectAll();
this.tbxText.SelectionLength = 0;
}
}
public static bool OpenTabTip()
{
bool result = false;
// reset the main window handle
TabTip._keyboardMainWindowHandle = IntPtr.Zero;
string osk = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "system32"), "osk.exe");
string pathX64 = Environment.ExpandEnvironmentVariables("%ProgramW6432%");
string pathX32 = Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%");
// in case of 32 bit systems
if (osk.Contains(pathX32))
osk = osk.Replace(pathX32, pathX64);
// start the keyboard process
ProcessStartInfo startInfo = new ProcessStartInfo(osk);
Process tmp = System.Diagnostics.Process.Start(startInfo);
// wait until starting the process has been finished
//result = tmp.WaitForInputIdle(5000);
// refresh the process information
tmp.Refresh();
}