Solved

Checkbox on 3rd Column of Listview

Posted on 2002-07-18
5
308 Views
Last Modified: 2008-03-17
I want to display a listview with the check box being displayed in the 3rd column.
eg

Name         Age     Close
-------     -----   ---------
Mary         28      [] (<- this being the checkbox)

At the moment I can only seem to get the checkbox value in the first column
Here is the code I have at the moment:
Dim itmAdd As ListItem
lvwList.View = lvwReport
lvwList.Checkboxes = True
lvwList.ColumnHeaders.add , , "Namw", lvwList.Width / 3
lvwList.ColumnHeaders.add , , "Age", lvwList.Width / 3
lvwList.ColumnHeaders.add , , "Close", lvwList.Width / 3
Set itmAdd = lvwList.ListItems.add(, , "Mary")
itmAdd.SubItems(1) = "28"

Any suggestions???
0
Comment
Question by:amgavin
5 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7161843
I think that is the default property of the Listbox, ie Style=1 Checkbox which makes the checkbox to the extreme left and not in any columns

maybe you can try a workaround...

-priya

0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7161860
sorry it should be ListView

The default property of the ListView, ie checkbox=true which makes the checkbox to the extreme left.

Also i think you might be wanting to read those values which are checked by the user, why not at run time, read those elements who's checkbox is checked.

hope this helps!

-priya

0
 
LVL 4

Expert Comment

by:gencross
ID: 7163089
I don't think you are going to be able to have a checkbox in a subitem.

Alternatively you could use the itemclick event and just change 'Close' to true or false or yes or no when the item is clicked...

Private Sub lvwList_ItemClick(ByVal Item As MSComctlLib.ListItem)
   
    If Item.SubItems(2) = "Yes" Then
        Item.SubItems(2) = "No"
    Else
        Item.SubItems(2) = "Yes"
    End If
   
End Sub

Once the user is finished choosing iterate through the list checking to see which are "Yes" and which are "No" and do what you want to with them.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8013960
Hi amgavin,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

amgavin, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 8095644
Question placed in PAQ

Computer101
E-E Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question