请教datagrid问题
本帖最后由 bcrun 于 2013-03-25 16:58:13 编辑 datagrid我单机表格中的某一行,将某一行的数据插入到新表里
现在的问题是,我单击的时候,msgbox显示的数据是正确的,但datagrid里数据会变,都变成cinvcode了,第二个,在点击command是,ss(2)能显示数值,ss(0),ss(1)都没值是怎么回事,
我这是个三列的datagrid,哪位大侠帮看看,谢谢!
Private Sub Command2_Click()
Dim conn As New ADODB.Connection
Dim strc As String
strc = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=erp;Data Source=127.0.0.1"
conn.Open strc
Dim strsql As String
MsgBox (ss(2))
'strsql = "insert into tt(cinvname,cinvstd) values (" & ss(1) & "," & ss(2) & ")"
'conn.Execute (strsql)
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
bm = DataGrid1.Row
k = DataGrid1.Columns.Count
For ic = 0 To k - 1
ReDim ss(ic)
DataGrid1.Row = bm
DataGrid1.Col = ic
ss(ic) = DataGrid1.Text
MsgBox (ss(ic))
Next ic
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
bm = DataGrid1.Row
k = DataGrid1.Columns.Count
ReDim ss(k) '改这里
For ic = 0 To k - 1
DataGrid1.Row = bm
DataGrid1.Col = ic
ss(ic) = DataGrid1.Text
MsgBox (ss(ic))
Next ic
End Sub