vb6将复选框添加到datagrid中

时间:2015-08-18 09:02:38

标签: datagrid vb6

我想在datagrid中添加checkbox并从checked行中获取值以插入到数据库中。我在向列中添加列和行时尝试使用ADODB记录集。这就是我一直在努力的方法:

Set rs = New ADODB.Recordset

    Set rs = New ADODB.Recordset

rs.Fields.Append "No", adInteger

rs.Fields.Append "Nama Subdataset", adVarChar, 50

rs.Fields.Append "Kode Subdataset", adVarChar, 50

rs.Fields.Append "Include", adInteger, , adFldMayBeNull

rs.Fields.Append "Selected", adBoolean, , adFldMayBeNull

rs.CursorType = adOpenKeyset

rs.CursorLocation = adUseClient

rs.LockType = adLockPessimistic

rs.Open

Set DataGrid1.DataSource = rs

'get the Grid's Recordset and add a new Record

Set rs = DataGrid1.DataSource

'Menampilkan list dataset ke table DataGrid1

For i = 1 To jml_subdataset


rs.AddNew Array("No", "Nama Subdataset", "Kode Subdataset", "Include", "Selected"), Array(i, nama_subdataset(i), kode_subdataset(i), Null, Null)

Next i

    rs.Update

    rs.MoveNext

然后我尝试将复选框添加到"选中"第(5)栏:

设置布尔格式

Set fmtBooleanData = New StdDataFormat
  fmtBooleanData.Type = fmtBoolean
  fmtBooleanData.TrueValue = "Yes"
  fmtBooleanData.FalseValue = "No"
  fmtBooleanData.NullValue = ""
Set DataGrid1.Columns(5).DataFormat = fmtBooleanData

但是我得到了错误,它说 - >编译器错误:用户定义的类型未定义

然后我确保在引用上检查Microsoft ActiveX数据对象Recordsets ..

0 个答案:

没有答案