C# – Windows CE textbox Focus problem

c++compact-frameworkfocuswindows-ce

I have a problem setting the focus back to a textbox. I run the same application both on Windows Ce and Windows Mobile 5 and the issue is only on WinCE.
On a form i have a custom control (let's say a custom DropDown) and a textbox, after an item is selected in the custom control i want to pass the focus back to the textbox.

The code looks like this:

private void ddlCurrencyList_SelectedItemChanged(object sender, SelectedItemArgs e)
{
    _selectedCurrency = CurrencyCollection.Find(ddlCurrencyList.SelectedValue);
    txtTabValue.Focus(); //does not work on Win CE. 
}

I can't figure out what steals the focus on WinCe.

Best Solution

I would guess that the list regains the focus after calling the event. Maybe it would help to invoke the call to txtTabValue.Focus() in a separate thread that just waits a couple of milliseconds and then calls txtTabValue.Focus() in the thread context of the form? Seems a bit over the top but might work - strange things happen when using the Compact Framework ;-)