Focus Question

M

Michael Hesse

Hi,

I am trying to set the focus to a text box after the user selects an item
from a ListView. Here is what I am trying:

Private Sub lv1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles lv1.SelectedIndexChanged

if lv1.SelectedItems.Count = 0 Then Exit Sub

lbl1.Text = lv1.SelectedItems(0).Text()

txt1.Focus()

End Sub

The problem is that the cursor seem to go briefly to the TextBos txt1, but
then focus returns to the item on the ListView that I originally selected.

Does anyone have any suggestions?

Thanks.
 
C

Cor

Hi Michael,

Is this your complete code.

I ask it because normaly is used for things like this
Private Sub lv1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles lv1.SelectedIndexChanged

if lv1.SelectedItems.Count > 0 Then
lbl1.Text = lv1.SelectedItems(0).Text
txt1.Focus()
End if
End Sub

So it seems to me that you have more behind that code?

Cor
 

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