>How to display CheckBox for those field that are Boolean data type
>in a DataGrid?
>I use the ADO DataGrid and set the DataSource = rsList.
>
>rsList is a ADODB RecordSet, and records are taken from a
>Access 2000 Table with some field declared as Boolean(True/False).
You cannot have a checkbox column to the DataGrid but you can and a Yes/No column this way (you have to set a reference to Microsoft Data Formatting Object Library):
Dim fmtBooleanData As StdDataFormat
With grdImport
.Columns(0).Locked = True
' set up Boolean Formatting
Set fmtBooleanData = New StdDataFormat
fmtBooleanData.Type = fmtBoolean
fmtBooleanData.TrueValue = "Yes"
fmtBooleanData.FalseValue = "No"
fmtBooleanData.NullValue = "No"
Set .Columns(0).DataFormat = fmtBooleanData
End With
To change its value, you can use:
Private Sub grdImport_DblClick()
grdImport.Columns(0).Value = Not grdImport.Columns(0).Value
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com