DELPHI里很容易解决,VB里就这么难吗?在VSFlexGrid表格里画线问题(DrawCell里写代码)。
能画出这样的效果我给300分。
http://www.cwsoft.net/money1.jpg
能画出这样的效果我给500分。
http://www.cwsoft.net/money2.jpg最好给代码例子,能把它搞成自定义控件就最好了。MailTo:[email protected]以下是参考的例子。是也是画的例子。VS自代的。Private Sub fa_DrawCell(ByVal hDC As Long, ByVal Row As Long, ByVal col As Long, ByVal left As Long, ByVal top As Long, ByVal right As Long, ByVal bottom As Long, done As Boolean)
    Dim clr&, clrg&, l&
    Dim rc As RECT
    Dim rc1 As RECT
    Dim clr1$, clr2$
    Dim r1%, g1%, b1%
    Dim r2%, g2%, b2%
    Dim rg%, gg%, bg%    
    With fa   
        ' make sure we need to draw this guy
        clr1 = .TextMatrix(Row, 0)
        clr2 = .TextMatrix(Row, 1)
        If Row > 0 And col = 2 And clr1 <> "" And clr2 <> "" Then    
            ' get rectangle
            rc.left = left
            rc.top = top
            rc.right = right
            rc.bottom = bottom           
            ' draw frame
            clr = SetBkColor(hDC, 0)
            ExtTextOut hDC, rc.left, rc.top, ETO_OPAQUE, rc, " ", 1, l
            InflateRect rc, -1, -1            
            ' get colors
            GetRGB clr1, r1, g1, b1
            GetRGB clr2, r2, g2, b2            
            ' show color
            rc1 = rc
            For l = rc.left To rc.right Step 3
                rg = r1 + (l - rc.left) * (r2 - r1) / (rc.right - rc.left)
                gg = g1 + (l - rc.left) * (g2 - g1) / (rc.right - rc.left)
                bg = b1 + (l - rc.left) * (b2 - b1) / (rc.right - rc.left)
                clrg = RGB(rg, gg, bg)
                SetBkColor hDC, clrg
                rc1.left = l
                ExtTextOut hDC, rc1.left, rc1.top, ETO_OPAQUE, rc1, " ", 1, l
            Next            
            ' done, restore hDC and quit
            SetBkColor hDC, clr
            done = True        
        End If    
    End With    
End Sub

解决方案 »

  1.   

    用不着在DRAWCELL中写代码,只需用MergeCol方法将标题行合并就行了
    至于画线嘛,你可以先用SELECT方法选定一个范围,再设置边框的大小及颜色即可
      

  2.   

    tangbei(成心) 
    能帮我写一个简单的例子吗?我对VB不熟。我是一直用delphi的。成功了500分全给你。
      

  3.   

    这个问题比较简单,可以通过合并单元格来实现
    后面的哪个图的标题可以看做是2行和12列的合并,具体代码我不写了,重复工作而已
    我给你关键的代码部分:
        With MSHFlexGrid1
            .FixedRows = 2 //标题行数
            .MergeCells = flexMergeFree  //自由合并
            .row = 0 
            .MergeRow(0) = True //合并第一行
            .ColAlignmentFixed = flexAlignCenterCenter
            .TextMatrix(0, n) = text
            .TextMatrix(0, n+1) = text
            ........................
            .TextMatrix(0, n+11) = text  //完成上半部分12列的合并
            //然后对其他单元格进行2行的合并
            .TextMatrix(0, col) = text1
            .TextMatrix(1, col) = text1
            .MergeCol(col) = True
        End With那条红线我不知道怎样画,等别的高手指点吧