UserControl, Focus() and missing cursor

  • Thread starter Thread starter Marius Horak
  • Start date Start date
M

Marius Horak

I have a user control, textbox and treeview.
After selecting a node textbox.text is set to selected node.text.
The next command is textbox.Focus(). After that textbox.Focused is true
but the cursor is missing. Tried Refresh, Update, SelectNextControl,
nothing helps. The cursor is missing. Any ideas how to get it visible?

Thanks

MH
 
I haven't encountered this problem myself, but the docs state:

"Focus is a low-level method intended primarily for custom control authors.
Instead, application programmers should use the Select method or the
ActiveControl property for child controls, or the Activate method for
forms."

Since you're using a UserControl, rather than a Control, you might find
better success with Select or ActiveControl.
 
I haven't encountered this problem myself, but the docs state:

"Focus is a low-level method intended primarily for custom control authors.
Instead, application programmers should use the Select method or the
ActiveControl property for child controls, or the Activate method for
forms."

Since you're using a UserControl, rather than a Control, you might find
better success with Select or ActiveControl.

Hi,

Try to forward focus events from the user controls to the textbox.

Moty
 
Thanks. Nothing works.

I think I was in a hurry when I posted my problem.

The TextBox and TreeView are part of my UserControl.
They are the only controls inside my UserControl.

After Select, ActiveControl, Focus the TextBox becomes Focused control
but there is no caret.

MH
 
That's an odd problem. Thanks for posting the workaround. Sorry I didn't
read your original post as carefully as I should have.
 
Back
Top