VB6: MshFlexGrib with a CheckBox

Hi,

How can I add a CheckBox to a MsFlexGrib?
(I have a few fields and I need that one of them will be a CheckBox).



Thanks.
LVL 2
2AngelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
You can add a graphic that looks alike to a checked/uncheck checkbox, yet you can't add a actual checkbox on MSFlexgrid.

Or my suggestion is try to use ListView Control instead, where we can change its view style to Report (list) and can have a checkbox on each row of it. Let us know if you're interested to use ListView.

regards
0
2AngelAuthor Commented:
Hi,

I found this: http://vbnet.mvps.org/index.html?code/comctl/lvledger.htm 
but a ListView is for VB.NET not for VB6 - isn't it?

Tks
0
Ryan ChongCommented:
>>but a ListView is for VB.NET not for VB6 - isn't it?
No, you can find the ListView Control from M$ Windows Common Control x.0 Library (x = 5 for VB5, 6 for VB6)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

2AngelAuthor Commented:
OK - I found the control - thanks!!!
Is the above link is good for me?

Tks
0
Ryan ChongCommented:
Yes, that's a good link, and there are more good stuffs to look through! 8-) yet for a easy sample, you can try below scripts:

'Add a ListView called ListView1 to your form, then add like:

Private Sub Form_Load()
    ListView1.ColumnHeaders.Add 1, , "Header 1"
    ListView1.ColumnHeaders.Add 2, , "Header 2"
    ListView1.FullRowSelect = True
    ListView1.CheckBoxes = True
    ListView1.LabelEdit = lvwManual
    ListView1.View = lvwReport
   
    For i = 1 To 20
        ListView1.ListItems.Add i, , "item " & i
        ListView1.ListItems(i).SubItems(1) = "subitem " & i
    Next i
   
End Sub

Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    MsgBox "You had " & IIf(Item.Checked, "checked", "unchecked") & " " & Item.Text
End Sub

Hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongCommented:
Add a command button named Command1 and add below scripts if you want to check the list which items are checked.

Private Sub Command1_Click()
    For i = 1 To ListView1.ListItems.Count
        If ListView1.ListItems(i).Checked Then Debug.Print ListView1.ListItems(i).Text & " is selected"
    Next i
End Sub
0
Ryan ChongCommented:
>>If ListView1.ListItems(i).Checked Then Debug.Print ListView1.ListItems(i).Text & " is selected"
typo.. should be as:

If ListView1.ListItems(i).Checked Then Debug.Print ListView1.ListItems(i).Text & " is checked"
0
2AngelAuthor Commented:

You are a very "nice" person - thank you!

I'll accept your answere but I'll increase the points for answering that:
I would like to get the data showing on that ListView comming from Access table on db.mdb file.

Thanks again!
0
Ryan ChongCommented:
Glad to have helps here 8-)

>>I would like to get the data showing on that ListView comming from Access table on db.mdb file.
Typically we'll use ADO objects to connect to database. For Access, we usually using OLEDB Connection. And to fill in your listview with data, you need to define 2 objects:

a ADODB.Connection object
a ADODB.Recordset object

A sample example will be provided shortly..
0
Ryan ChongCommented:
ADO's OLEDB ConnectionString Reference:
http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJet

Here is an example on How to load database's data into ListView:
http://www34.brinkster.com/yshub/download/ADO_ListView.zip

Hope this helps

0
2AngelAuthor Commented:
TKS!!!
0
2AngelAuthor Commented:
P.S. - just now a saw your profile:
>>>::: Pray for World Peace :::
I'm with you man........ :-))
0
Ryan ChongCommented:
::: 8-) :::
0
2AngelAuthor Commented:
Hi again,

I'm sorry to distrub u again but can algin the text in the ListView to center or right?

Thanks again.
0
Ryan ChongCommented:
Hi 2Angel,

You should ask this question in a New Question, since it's different from what you're asking from the Question Title, and as this question is already closed ;-)



To set the columns alignment:

Try goto ListView Properties, then select Column Headers tab, you should able to set the Alignment there..

or you can do it programmingly as like:

ListView1.ColumnHeaders(2).Alignment = lvwColumnCenter 'or lvwColumnRight, lvwColumnLeft

Please note 1st column MUST align to Left.

cheers
0
2AngelAuthor Commented:
Hi,

Many thanks for you.

I am sorry for asking 2 questions, so, I posted a new one just for you:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21226029.html

Please responed there so I can accept your comment and give the points to you.


Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.