UserControl, Focus() and missing cursor

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
 
B

Brian Schwartz

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.
 
M

Moty Michaely

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
 
M

Marius Horak

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
 
B

Brian Schwartz

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top