问题描述如下:
数据在vsflexgrid(名称为vsf1)中显示
  如下格式:
  姓名    年龄     性别   地址
  张三    30        男    北京市
  李四    20        男    杭州市
点"预览"按钮,调用如下代码:
Dim rpt As New activereport1
Set rpt.Grid = vsf1
rpt.ShowActiveReport1中的代码如下:
Private m_grid As VSFlexGrid
Private bDone As BooleanProperty Set Grid(grd As VSFlexGrid)
Dim ctl As Object
Dim iLeft As Integer
Dim i As Integer
    Set m_grid = grd
    
    For i = 0 To m_grid.Cols - 1
        Set ctl = Detail.Controls.Add("DDActiveReports2.Field")
        ctl.Left = iLeft
        ctl.Top = 0
        ctl.Width = m_grid.ColWidth(i)
        ctl.Tag = i
        Fields.Add ctl.Name
        ctl.DataField = ctl.Name
        ctl.BorderStyle = 1
        
        iLeft = iLeft + ctl.Width + 144
        PrintWidth = iLeft
    Next i
End PropertyPrivate Sub ActiveReport_FetchData(eof As Boolean)
Static iRow As Integer
Dim ctl As Object
Dim i As Integer    If iRow < m_grid.Rows Then
        For Each ctl In Detail.Controls
            m_grid.Row = iRow:  m_grid.Col = ctl.Tag
            Fields(ctl.Name).Value = m_grid.Text
        Next
        iRow = iRow + 1
        eof = False
    End If
End Sub
结果能正确显示,可是不能显示表格线,请问如何才能显示表格线呢?

解决方案 »

  1.   

    用vsprint 配合vsflexgrid不錯
      

  2.   

    我看用Excel加上图表操作比较方便。
      

  3.   

    ctl.Border.BottomColor = vbBlack
                 ctl.Border.LeftColor = vbBlack
                 ctl.Border.RightColor = vbBlack
                 ctl.Border.TopColor = vbBlack
                 ctl.Border.BottomStyle = ddBLSolid
                 ctl.Border.LeftStyle = ddBLSolid
                 ctl.Border.RightStyle = ddBLSolid
                 ctl.Border.TopStyle = ddBLSolid
                 If i = iTotalFields - 1 Then
                    ctl.Border.RightColor = vbBlack
                    ctl.Border.RightStyle = ddBLSolid