Dim currentrow As IntegerPrivate Sub Combo1_Click() DataGrid1.Row = currentrow DataGrid1.Col = 0 DataGrid1.Text = Combo1.Text End SubPrivate Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer) currentrow = DataGrid1.Row Combo1.Visible = True Combo1.Move DataGrid1.Left + DataGrid1.Columns(0).Left, DataGrid1.Top + DataGrid1.Row * (DataGrid1.RowHeight) + (DataGrid1.HeadLines) * 195, DataGrid1.Columns(DataGrid1.Col).Width + 50 If DataGrid1.Columns(DataGrid1.Col).Text <> "" Then Combo1.Text = DataGrid1.Columns(DataGrid1.Col).TextEnd SubPrivate Sub Form_Load() Dim adoRecordset As New ADODB.Recordset Dim i As Integer For i = 0 To 5 '为Recordset六个字段,即为 DataGrid 添加六列 adoRecordset.Fields.Append "n * " & i + 1, adVariant, , adFldMayBeNull + adFldIsNullable + adFldUpdatable Next i adoRecordset.Open For j = 0 To 4 adoRecordset.AddNew '加五条记录,即为 DataGrid 添加五空行 Next j Set DataGrid1.DataSource = adoRecordset '绑定 DataGrid 的数据源 adoRecordset.MoveFirst For i = 0 To 5 For j = 0 To 4 DataGrid1.Row = j DataGrid1.Col = i DataGrid1.Text = (i + 1) * (j + 1) Next NextFor i = 1 To 10 Combo1.AddItem Chr(i + 64) Next End Sub
CmbBox.Top = Grd.CellTop + Grd.Top
CmbBox.Width = Grd.CellWidth
CmbBox.Visible = True
CmbBox.Text = Grd.TextMatrix(Grd.Row, Grd.Col)
DataGrid1.Row = currentrow
DataGrid1.Col = 0
DataGrid1.Text = Combo1.Text
End SubPrivate Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
currentrow = DataGrid1.Row
Combo1.Visible = True
Combo1.Move DataGrid1.Left + DataGrid1.Columns(0).Left, DataGrid1.Top + DataGrid1.Row * (DataGrid1.RowHeight) + (DataGrid1.HeadLines) * 195, DataGrid1.Columns(DataGrid1.Col).Width + 50
If DataGrid1.Columns(DataGrid1.Col).Text <> "" Then Combo1.Text = DataGrid1.Columns(DataGrid1.Col).TextEnd SubPrivate Sub Form_Load()
Dim adoRecordset As New ADODB.Recordset
Dim i As Integer
For i = 0 To 5 '为Recordset六个字段,即为 DataGrid 添加六列
adoRecordset.Fields.Append "n * " & i + 1, adVariant, , adFldMayBeNull + adFldIsNullable + adFldUpdatable
Next i
adoRecordset.Open
For j = 0 To 4
adoRecordset.AddNew '加五条记录,即为 DataGrid 添加五空行
Next j
Set DataGrid1.DataSource = adoRecordset '绑定 DataGrid 的数据源
adoRecordset.MoveFirst
For i = 0 To 5
For j = 0 To 4
DataGrid1.Row = j
DataGrid1.Col = i
DataGrid1.Text = (i + 1) * (j + 1)
Next
NextFor i = 1 To 10
Combo1.AddItem Chr(i + 64)
Next
End Sub