Set rs = conn.Execute(Statement) //rs has 6 fields
我想将当前的rs行添加到DataGrid。我怎么能这样做?
样品:
DataGrid1.<someFunction (say AddRow)> = <some operations with rs.Fields (say, Str(rs.Fields(0)) & rs.Fields(1) & rs.Fields(2) & Str(rs.Fields(3)) & Str(rs.Fields(4)) & Str(rs.Fields(5)) >;
答案 0 :(得分:1)
您可以添加这样的新行。
DataGrid1.Rows = DataGrid1.Rows + 1
和这样的列
DataGrid1.Cols = DataGrid1.Cols + 1
之后你可以像这样填充网格。
DataGrid1.TextMatrix(<row>,<column>) = rs.Fields(0)
DataGrid1.TextMatrix(<row>,<column+1>) = rs.Fields(1)
答案 1 :(得分:0)
这是oldschool,但是如何将整个记录集一次绑定到datagrid:
Set DataGrid1.DataSource = rs
DataGrid1.Refresh