I am using listbox with checkboxes into it & I want to opearte that listbox only with mouse not with keyboard then is that possible to do that? if yesthen please give any instant solution......Thanx. :)
Printable View
I am using listbox with checkboxes into it & I want to opearte that listbox only with mouse not with keyboard then is that possible to do that? if yesthen please give any instant solution......Thanx. :)
You can just cancel all of the KeyPresses going to it.Quote:
Originally Posted by shirishdawane
VB Code:
Private Sub List1_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub
Actually I am doing in this way :Quote:
Originally Posted by Comintern
VB Code:
Private Sub lstregno_ItemCheck(Item As Integer) For i = 0 To lstregno.ListCount - 1 If lstregno.Selected(i) = True Then lstregno.Selected(i) = False End If Next lstregno.Selected(lstregno.ListIndex) = True End Sub
but when I try to select/ disselect checkboxes with "Spacebar" button then it goes into infinite loob of FOR loop & shows error " Out of Stack". o is there any way to check that space bar has bben pressed ?
Quote:
Originally Posted by shirishdawane
VB Code:
Private Sub List1_KeyPress(KeyAscii As Integer) if KeyAscii <> 32 then KeyAscii = 0 End Sub
Check for spacebar presses by testing the KeyAscii against 32. If you are somehow generating an infinite loop by recursing the function, add a static indicator to check if the code is in progress:
VB Code:
Private Sub List1_KeyPress(KeyAscii As Integer) Dim iItem As Integer Static bInProg As Boolean If bInProg = False Then If KeyAscii = 32 Then 'Check for space For iItem = 0 To List1.ListCount - 1 If List1.Selected(iItem) = True Then List1.Selected(iItem) = False End If Next bInProg = True List1.Selected(List1.ListIndex) = True bInProg = False Else KeyAscii = 0 End If End If End Sub
Thanx guys it works. :wave: