Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check Box in DataGrid
Message
 
À
06/09/2000 03:29:01
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00412805
Message ID:
00412863
Vues:
14
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform