分类:
2009-10-11 13:48:20
来源:cww 有一个最简单的方式,便是使用MSRDC控制项,而後将MSFlexGrid的DataSource设定为该 MSRDC控制项,不过,透过MSRDC来做事情,在Performance上可能有所折扣,如果不用 MSRDC,可以使用以下的程序码片断。 Private rs As rdoResultset Private qry As rdoQuery . . Dim str5 As String, i As Long Set rs = qry.OpenResultset(rdOpenKeyset, rdConcurReadOnly) rs.MoveLast '将取得所有的资料 rs.MoveFirst '把所有的资料放入str5中,内定格式为Column间以Tab分隔,不同 '的Row以chr(13)分隔 str5 = rs.GetClipString(rs.RowCount) With MSFlexGrid1 .Rows = rs.RowCount + 1 '设定MSFlexGrid的列数 .Cols = rs.rdoColumns.Count + 1 '设定MSFlexGrid的行数 '以下设定Title为栏位名称 .Row = 0 For i = 0 To rs.rdoColumns.Count - 1 .Col = i + 1 .Text = rs.rdoColumns(i).Name Next '将MSFlexGrid的资料区整个Mark起来 .Col = 1: .Row = 1 .RowSel = .Rows - 1: .ColSel = .Cols - 1 '设定MSFlexGrid的资料 .Clip = str5 '取消MSFlexGrid的选取 .RowSel = 1: .ColSel = 1 End With