Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a check box be made to appear as a cell in the DBGrid control? 2

Status
Not open for further replies.

ibanezGuitars

Programmer
Jul 8, 2004
22
US
Hello,

I am working on a project in VB6 (SP5) which uses DAO and Access databases. Can anyone tell me if the check box can be made to appear as a cell in the DBGrid control? If not, is there a way to build such a control in VB6?

Any code snippets, sites or suggestions would be greatly appreciated.

Thanks for your time,

Dave
 
I do something similar using a MsFlexgrid and a textbox to edit records.

you can do the same thing with a checkbox just hacked this together to test:

Private Sub MSFlexGrid1_Click()
With MSFlexGrid1

If (.Col = 3) Then

Check1.Move .CellLeft + .Left, .CellTop + .Top, _
.CellWidth, .CellHeight
Check1.Visible = True
Check1.SetFocus
End If

End With

End Sub
 
I do it all the time. Just as was just mentioned, you fake it by putting the checkbox on top, and position it so it looks like it's in the cell. I'll usually make a checkbox control array, with index 0 located at row 0 of the grid, hidden. (or use it as a select all, de-select-all functionality) Then for each .additem load a new checkbox, and position it. In this way each checkbox's index will equal the grid's row number.
If you use the datasource property to populate the grid, you'll just have to figure out how many rows of data you have, and then load the checkboxes seperately, but same effect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top