现我从数据库中查询很多数据,显示在MSFlexGrid1和MSFlexGrid2上,现在需要打印
我该如何实现打印,能使两个报表中的每列对齐成一直线,如果数据没有表头长,则缩进到表头
中心位置,居中对齐。

解决方案 »

  1.   

    用空格填充多余的位置,或指定多个制表符的位置,必要时可用format格式话字串
      

  2.   

    谢谢junki大哥,但我没有收到你的代码啊!
    真的很急,请你现在发给我,好吗???
      

  3.   

    '还好,还在,功能不是很完善,你可以作相应的修改
    Private Function LeftSpaces(ByVal ColPos As Integer, ByVal Date_Str As String) As Integer    Dim Str_Pos      As Integer
        Dim ByteWidth    As Integer
        Dim Grid_Len      As Integer
        Dim Date_Len      As Integer
        Dim Date_ChineseCount As Integer
        
        Date_ChineseCount = 0
        ByteWidth = 90
        
        If ColPos = ResultTable.ResultGrid.Cols - 2 Then
            Grid_Len = 630
        Else
            Grid_Len = 1080
        End If
        
        Date_Len = Len(Date_Str)
        For Str_Pos = 1 To Len(Date_Str)
            If Asc(Mid(Date_Str, Str_Pos, 1)) < 0 Then
                Date_ChineseCount = Date_ChineseCount + 1
            End If
        Next Str_Pos
        Date_Len = Date_Len + Date_ChineseCount    If Date_Len = 12 Then
            LeftSpaces = Grid_Len / ByteWidth - Date_Len + 1
        Else
            LeftSpaces = Grid_Len / ByteWidth - Date_Len - 1
        End If
        
    End Function