我加载了一个MSFlexGrid 控件,现在想把第一行的第一、二列合并,第一、二行的第三列合并……怎么用代码实现?— —|—|—|— —|
—|—|—|—|—|—|最好有MSFlexGrid 控件的使用代码范例

解决方案 »

  1.   

    好像看见过.
    给点代码你看看.
    Sub DoInitialSettings()    Dim i%
        flex.Row = 0
        flex.ColAlignment(0) = 7
        
        For i = 0 To flex.Cols - 1
        
            flex.Col = i
            flex.CellFontSize = 14
            flex.CellAlignment = 4
            
            flex.MergeCol(i) = True     
            flex.ColWidth(i) = 2000         Next i
        
        flex.MergeCells = flexMergeRestrictColumns
        
    End Sub
      

  2.   

    Private Sub flex_DragDrop(Source As VB.Control, X As Single, Y As Single)
        If flex.Tag = "" Then Exit Sub
        flex.Redraw = False
        flex.ColPosition(Val(flex.Tag)) = flex.MouseCol
        DoSort
        flex.Redraw = True
    End Sub
      

  3.   

    Private Sub flex_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        flex.Tag = ""
        If flex.MouseRow <> 0 Then Exit Sub
        flex.Tag = Str(flex.MouseCol)
        flex.Drag 1
      

  4.   

    单元格内的数据相同才能合并
      
      Dim i As Integer
      
      flxgSample.MergeCells = flexMergeFree
      
      '第一行,一二列
      flxgSample.Row = 1
      For i = 1 To 2
        flxgSample.Col = i
        flxgSample.Text = " "
      Next i
      flxgSample.MergeRow(1) = True
      
      '第三列,一二行
      flxgSample.Col = 3
      For i = 1 To 2
        flxgSample.Row = i
        flxgSample.Text = "  "
      Next i
      flxgSample.MergeCol(3) = True
      

  5.   

    我试过OK哦,源代码如下:Private Sub Form_Load()
      MSHFlexGrid1.Cols = 23
      MSHFlexGrid1.Rows = 10
      MSHFlexGrid1.FixedRows = 2
      MSHFlexGrid1.FixedCols = 0
      
      Load_MSHFlexGrid_Head
    End Sub
    Private Sub Load_MSHFlexGrid_Head()
      MSHFlexGrid1.Row = 0
      MSHFlexGrid1.Col = 0
      MSHFlexGrid1.Text = "年"
      MSHFlexGrid1.Row = 0
      MSHFlexGrid1.Col = 1
      MSHFlexGrid1.Text = "年"
      
      MSHFlexGrid1.Row = 1
      MSHFlexGrid1.Col = 0
      MSHFlexGrid1.ColWidth(0) = 500
      MSHFlexGrid1.Text = "月"
      
      MSHFlexGrid1.Row = 1
      MSHFlexGrid1.Col = 1
      MSHFlexGrid1.ColWidth(1) = 500
      MSHFlexGrid1.Text = "日"
      
      MSHFlexGrid1.MergeCells = flexMergeFree
      MSHFlexGrid1.MergeRow(0) = True
      MSHFlexGrid1.MergeCol(0) = True
      MSHFlexGrid1.MergeCol(1) = True
    End Sub