focus bug on listview ?
Hi,
I (again) have problems with VB for pocket PC (VS 2005 Beta 2 using framework 2.0 for Pocket PC)...
here's my new one :
I have a form where 2 listviews are to be displayed one after another (I chose it because some informations had to be visibile for both functionnalities)
I show my first listview, once the user click on a row, I hide the first listview then shows the second one, but the problem is that the focus is still on the FIRST listview. I saw there was this bug on eVB3.0, I hope it had been fixed and / or another solution exists.
Here's my code :
| |
PrivateSub LVComptes_SelectedIndexChanged(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles LVComptes.SelectedIndexChanged Dim ValueAsString If LVComptes.SelectedIndices.Count < 1ThenExitSub Value = LVComptes.Items(LVComptes.SelectedIndices(0)).Text IfNot isPartOfType(Value)Then LVComptes.Visible =False LVDetail.Visible =True LVDetail.Focus() Application.doEvents() EndIf EndSubPrivateSub LVDetail_GotFocus(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles LVDetail.GotFocus Cursor.Current = Cursors.WaitCursor LVComptes.Visible =False LVComptes.SendToBack() init_LVDetail(getCompteWhere(LVComptes.Items(LVComptes.SelectedIndices(0)).Text)) CmbDetail.Visible =True cmbOperation.Visible =False CmbDevise.Visible =True LblCatTitre.Visible =True lblSoldeDetail.Visible =True CmbDeviseComptes.Visible =False Me.LblCatTitre.Text = "Compte : " & selCompte.getIDCompte Cursor.Current = Cursors.Default EndSub
|
everything's fine until I reach the end sub of LVComptes_SelectedIndexChanged, then, focus change and LVComptes takes back the focus. I still have the same problem when I hide LVDetail (cause I show other informations once the user click on one of its rows)
Any idea anyone?
thanks
[3361 byte] By [
Seta] at [2008-2-13]
The best way to avoid such problem is do all the work you want on LVComptes listview and avoid to perform any code in LVDetail_GotFocus() that would put focus back on LVCOmptes.
So simply remove the following code from LVDetail_GotFocus() and place it into LVComptes_SelectedIndexChanged
LVComptes.Visible = False
LVComptes.SendToBack()
Private Sub LVComptes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LVComptes.SelectedIndexChanged Dim Value As String
If LVComptes.SelectedIndices.Count < 1 Then Exit Sub
Value = LVComptes.Items(LVComptes.SelectedIndices(0)).Text
If Not isPartOfType(Value) Then
LVComptes.Visible = False
LVDetail.Visible = True
LVComptes.SendToBack()
LVDetail.Focus()
Application.doEvents()
End If
End Sub
Private Sub LVDetail_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles LVDetail.GotFocus
Cursor.Current = Cursors.WaitCursor
init_LVDetail(getCompteWhere(LVComptes.Items(LVComptes.SelectedIndices(0)).Text))
CmbDetail.Visible = True
cmbOperation.Visible = False
CmbDevise.Visible = True
LblCatTitre.Visible = True
lblSoldeDetail.Visible = True
CmbDeviseComptes.Visible = False
Me.LblCatTitre.Text = "Compte : " & selCompte.getIDCompte
Cursor.Current = Cursors.Default
End Sub
David