listview focus question

  • Thread starter Thread starter tmaster
  • Start date Start date
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
 
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.
 
* "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'?
 
Back
Top