[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB6: MshFlexGrib with a CheckBox

Posted on 2004-11-29
16
Medium Priority
?
372 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:2Angel
  • 9
  • 7
16 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696050
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
 
LVL 2

Author Comment

by:2Angel
ID: 12696130
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
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696158
>>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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:2Angel
ID: 12696210
OK - I found the control - thanks!!!
Is the above link is good for me?

Tks
0
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 800 total points
ID: 12696324
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
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696355
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
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696366
>>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
 
LVL 2

Author Comment

by:2Angel
ID: 12696417

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
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696653
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
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12696859
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
 
LVL 2

Author Comment

by:2Angel
ID: 12696931
TKS!!!
0
 
LVL 2

Author Comment

by:2Angel
ID: 12696989
P.S. - just now a saw your profile:
>>>::: Pray for World Peace :::
I'm with you man........ :-))
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12697058
::: 8-) :::
0
 
LVL 2

Author Comment

by:2Angel
ID: 12713886
Hi again,

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

Thanks again.
0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 12713960
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
 
LVL 2

Author Comment

by:2Angel
ID: 12715449
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

834 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