Aaron Gold
Newcomer
- Joined
- Oct 21, 2004
- Messages
- 1
I'm new VB.NET, so please excuse my ingorance.
I have a form with listview control as it's only control. It has the following changed default properties
VIEW set DETAIL
MULTISELECT set FALSE
I loaded the listview control from MySQL dataset containing 2 fields - description and corresponding code. I display the line number and description and stored the corresponding code in an array.
The listview would look something like this
1. item1
2. item2
3. item3
etc.
I numbered the items to allow my users to press number of the entry they want to select and press enter key. This seems to work partially for number 1. When I press 1, item11 is selected and every sucessive time I press 1 I'd select item11, item12 until it jumps to item1. Also, if I press any other number, the control does not consistently select the corresponding item number (it does not move from currently selected item)
I've included a code snipet, which I hope with help.
Private Sub lvBHRsn_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvBHRsn.Click
Dim Idx As Integer
If lvBHRsn.SelectedItems.Count > 0 Then
Idx = lvBHRsn.SelectedItems(0).Index
BHReasonCode = Aegon_BH_Codes(Idx) ' corresponding code
Close()
End If
End Sub
Private Sub lvBHRsn_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles lvBHRsn.KeyPress
Dim Idx As Integer
If Not e.KeyChar = vbCr Then
Exit Sub
End If
If lvBHRsn.SelectedItems.Count > 0 Then
Idx = lvBHRsn.SelectedItems(0).Index
If Aegon_BH_Codes(Idx) <> "" Then
BHReasonCode = Aegon_BH_Codes(Idx) ' corresponding code
Close()
End If
End If
End Sub
Thanks.
I have a form with listview control as it's only control. It has the following changed default properties
VIEW set DETAIL
MULTISELECT set FALSE
I loaded the listview control from MySQL dataset containing 2 fields - description and corresponding code. I display the line number and description and stored the corresponding code in an array.
The listview would look something like this
1. item1
2. item2
3. item3
etc.
I numbered the items to allow my users to press number of the entry they want to select and press enter key. This seems to work partially for number 1. When I press 1, item11 is selected and every sucessive time I press 1 I'd select item11, item12 until it jumps to item1. Also, if I press any other number, the control does not consistently select the corresponding item number (it does not move from currently selected item)
I've included a code snipet, which I hope with help.
Private Sub lvBHRsn_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvBHRsn.Click
Dim Idx As Integer
If lvBHRsn.SelectedItems.Count > 0 Then
Idx = lvBHRsn.SelectedItems(0).Index
BHReasonCode = Aegon_BH_Codes(Idx) ' corresponding code
Close()
End If
End Sub
Private Sub lvBHRsn_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles lvBHRsn.KeyPress
Dim Idx As Integer
If Not e.KeyChar = vbCr Then
Exit Sub
End If
If lvBHRsn.SelectedItems.Count > 0 Then
Idx = lvBHRsn.SelectedItems(0).Index
If Aegon_BH_Codes(Idx) <> "" Then
BHReasonCode = Aegon_BH_Codes(Idx) ' corresponding code
Close()
End If
End If
End Sub
Thanks.