Hi there,
i have got the problem that the UltraTextEditor does not receive the Input Focus when calling the Focus() Method.
First of all, i set the UltraTextEditor as Active Control and after that i call the Focus() Method.
Then the UltraTextEditor is Active but does not have the Input Focus.
When i switch to an other open window and return back to my window with the UltraTextEditor, it receives automatic the Input Focus.
Does anyone have an idea?
Thank you.
In what event are you calling the Focus method? Focus() will not work for any control inside events that occur before the form is shown. So that includes Form_Load.
i tried to call it in Load and Shown Event of the Form.
Every Time i checked the CanFocus Property, it was False.
Hm, I know this won't work in Form_Load, but I thought the purpose of the Shown event was to allow you to do things like this. I guess I was mistaken.
Another workaround is to use a BeginInvoke. So inside your Form_Load you call a BeginInvoke to invoke a method which sets focus to the control you want.
It works.
I don't see how they type of delegate could make any difference. Are you saying it's still not working?
The MethodInvoker was not the Problem..
The ActiveControl was the Problem.
As following it doesnt work:
this.ActiveControl = myControl;
this.ActiveControl.Focus();
Thank you!
the MethodInvoker makes the difference...
i used a common delegate to invoke my method.
thanks a lot and have a nice day.
I just tested this out and it works fine for me:
private void Form1_Load(object sender, EventArgs e) { this.BeginInvoke(new MethodInvoker(this.SetFocusToUltraTextEditor)); } private void SetFocusToUltraTextEditor() { this.ultraTextEditor1.Focus(); }