listview focus question

T

tmaster

I have a form, frmMain, that contains a listview. When the user selects
item(s), I do the following:

Private Sub lvwToDo_ItemActivate(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles lvwToDo.SelectedIndexChanged
Dim litem As ListViewItem
Dim frmTemp As New frmToDoDetail()

For Each litem In lvwToDo.SelectedItems
' Call another form to edit the listview selected item's fields:
frmTemp.edit(litem)
Next

End Sub

This works, but focus doesn't stay with frmTodoDetail. Instead,
frmTodoDetail ends up behind the original form, frmMain. I have tried using
the focus method to remedy the problem, as well as using different listview
events, withou success. What am I doing wrong?

Thanks
 
A

Armin Zingler

tmaster said:
I have a form, frmMain, that contains a listview. When the user
selects item(s), I do the following:

Private Sub lvwToDo_ItemActivate(ByVal sender As System.Object,
ByVal e
As System.EventArgs) Handles lvwToDo.SelectedIndexChanged
Dim litem As ListViewItem
Dim frmTemp As New frmToDoDetail()

For Each litem In lvwToDo.SelectedItems
' Call another form to edit the listview selected item's
fields:
frmTemp.edit(litem)
Next

End Sub

This works, but focus doesn't stay with frmTodoDetail. Instead,
frmTodoDetail ends up behind the original form, frmMain. I have tried
using the focus method to remedy the problem, as well as using
different listview events, withou success. What am I doing wrong?

You don't show frmToDoDetail, so I wonder how you can say that it does not
get the focus because it is not even visible.

Anyway, the Activate method might help.
 
H

Herfried K. Wagner [MVP]

* "tmaster said:
I have a form, frmMain, that contains a listview. When the user selects
item(s), I do the following:

Private Sub lvwToDo_ItemActivate(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles lvwToDo.SelectedIndexChanged
Dim litem As ListViewItem
Dim frmTemp As New frmToDoDetail()

For Each litem In lvwToDo.SelectedItems
' Call another form to edit the listview selected item's fields:
frmTemp.edit(litem)
Next

End Sub

This works, but focus doesn't stay with frmTodoDetail. Instead,
frmTodoDetail ends up behind the original form, frmMain. I have tried using
the focus method to remedy the problem, as well as using different listview
events, withou success. What am I doing wrong?

Where/how do you show 'frmTemp'?
 

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