|
-
Oct 16th, 2012, 08:42 AM
#1
Thread Starter
Fanatic Member
Checkbox in listview?
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
-
Oct 16th, 2012, 08:52 AM
#2
Re: Checkbox in listview?
There is a Checkbox-Property on the Property-Page of ListView and an ItemCheck-Event.....
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 16th, 2012, 09:10 AM
#3
Junior Member
Re: Checkbox in listview?
Hi, yes there is one.
Have a look at this.
ListView1.Columns.Add("Copyright", 0, HorizontalAlignment.Left)
ListView1.CheckBoxes = True
ListView1.View = View.Details
ListView1.FullRowSelect = True
ListView1.GridLines = True
-
Oct 16th, 2012, 09:34 AM
#4
Thread Starter
Fanatic Member
Re: Checkbox in listview?
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
-
Oct 16th, 2012, 09:47 AM
#5
Re: Checkbox in listview?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 17th, 2012, 04:15 AM
#6
Thread Starter
Fanatic Member
Re: Checkbox in listview?
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
"
-
Oct 17th, 2012, 04:47 AM
#7
Re: Checkbox in listview?
You have to build up your SQL-String dynamically inside the ItemCheck-Event.
Something like this:
Code:
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
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-String
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
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Dec 9th, 2018, 10:04 PM
#8
New Member
How to check all checkboxes in listview then display all values by row and column?
How to check all checkboxes in listview then display all values by row and column in textboxes at visual basic 6.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|