Hi guys, is it possible to have a checkbox in a listview for each item? and when the checkbox is ticked it do some code?
Thanks
Jamie
Printable View
Hi guys, is it possible to have a checkbox in a listview for each item? and when the checkbox is ticked it do some code?
Thanks
Jamie
There is a Checkbox-Property on the Property-Page of ListView and an ItemCheck-Event.....
Hi, yes there is one.
Have a look at this.
Quote:
ListView1.Columns.Add("Copyright", 0, HorizontalAlignment.Left)
ListView1.CheckBoxes = True
ListView1.View = View.Details
ListView1.FullRowSelect = True
ListView1.GridLines = True
Thanks a lot guys, really appreciate it, is it possible to add a check box in one of the subitems as appose to the first column in the listview?
thanks
Jamie
Hi guys,
I'm trying to make a filter listview, like excel's filter option.
Basically a checkbox of names, and what i want is when you tick each name then it will filter the database with each item checked, at the moment my db string is
"
Set rs = db.OpenRecordset("SELECT * FROM `Leads` WHERE `Agent` = " & "'" & listview1.selecteditem & "'")
how can i make it so agent is what ever the user has ticked?
Thanks,
Jamie
"
You have to build up your SQL-String dynamically inside the ItemCheck-Event.
Something like this:
Obviously you will have to check if it's the first checked item, since then you must not use the " AND"-Operator in your SQL-StringCode:Dim WhereClause as String
Private Sub MyListView_ItemCheck(ByVal Item As MSComctlLib.ListItem) 'I'M DOING THIS IN VBA, SO THE EVENT MIGHT LOOK DIFFERENT IN VB6
If Item.Checked the WhereClause=WhereClause & " AND Agent='" & Item.Text & "'" 'OR USE Item.ListSubItems
DoDatabaseQueryAndRepopulateListView
End Sub
The Problem you're going to run into:
Let's say you have 10 different Names first, and you tick off 3 names in your Checkboxlist.
If you requery your DB with the new SQL-String the other 7 Names will be gone!
If you really want to do something like Excel's Filter-Thingy you should try to hide the not corresponding lines (that's what Excel is actually doing) without doing a new Query on your DB
How to check all checkboxes in listview then display all values by row and column in textboxes at visual basic 6.0