Link to home
Start Free TrialLog in
Avatar of 2Angel
2Angel

asked on

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.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

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
Avatar of 2Angel
2Angel

ASKER

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
>>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)
Avatar of 2Angel

ASKER

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

Tks
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
>>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"
Avatar of 2Angel

ASKER


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!
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..
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

Avatar of 2Angel

ASKER

TKS!!!
Avatar of 2Angel

ASKER

P.S. - just now a saw your profile:
>>>::: Pray for World Peace :::
I'm with you man........ :-))
::: 8-) :::
Avatar of 2Angel

ASKER

Hi again,

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

Thanks again.
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
Avatar of 2Angel

ASKER

Hi,

Many thanks for you.

I am sorry for asking 2 questions, so, I posted a new one just for you:
https://www.experts-exchange.com/questions/21226029/VB6-Algin-text-in-ListView-Points-for-ryancys.html

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


Thanks again!