Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox select\unselect

Status
Not open for further replies.

GOOGE

Technical User
Jun 20, 2001
36
NZ
hi guys

I have a listbox with checkboxes, can i have vb execute a task when the checkbox is clicked and then execute a diff task when the checkbox is unslected, i need it to execute when the mouse is being clicked not one i have selected everything and then clicked a command button.

would i use the list1.checkitem command?

if so how do i use it and also how do i use it when the checkbox has been unselected?

thanks in advancew
James Cuttance
 
Just put the code in the ItemCheck event:

Private Sub List1_ItemCheck(Item As Integer)
'Code here
End Sub [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
thanks but how do i check to see if when the mouse is click it checking or unchecking?


thnaks again
James
 

I am not quite sure what you are asking but here is some sample code

[tt]
Private Sub Command1_Click()
If Check1.Value = vbChecked Then
'Place Checked Code Here
Else
'Place Unchecked Code Here
End If
End Sub

Private Sub List1_Click()
MsgBox List1.List(List1.ListIndex)
End Sub
[/tt]

Hope this helps, Good Luck
 
You need to use the event that I posted. The List Click event will fire even when a check box (which is in the list box next to the item)is not being clicked.
Seiings how you cannot have the MultiSelect property set to True, when using checkboxes (Style = 1), then the Selected property will reflect the state of the check box, and not act as normally expected (style = 0) when the item in the list is just highlighted.

Private Sub List1_ItemCheck(Item As Integer)
'The List Item selected (zero based) is held in the variable "Item"
msgbox "ItemChecked = " & List1.Selected(Item)
End Sub [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
ta guys its all working now,


thanks again

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top