本人想要一个:它应该是一个X行Y列的二维表格,X和Y可以根据需要确定,每一个表单元都可以用作文本输入,请问那位高手有这样的控件啊????
补充:用mshflexgrid好像不行,试过了,应为它是只读的,我想让这个程序在运行时,用户能通过键盘对表格里面的数据进行输入和修改,而mshflexgrid不行

解决方案 »

  1.   

    谁说不行的?下面的代码就可以任意设置x行y列的文本MSHFlexGrid1.TextMatrix(x, y) = "你想输入的字符串"只不过MSHFlexGrid1控件表格不能象EXCEL那样有输入状态,因此只能用文本框来代替,也就是说你添加一个隐藏的文本框,当用户点击(或双击)某一个单元格时,使文本框显示在该位置,让用户输入,输完后用上面的代码给单元格赋值。网上就有代码,你搜索一下。
      

  2.   

    fpspread
    http://download.csdn.net/source/293552
      

  3.   

    楼上的大虾,您推荐的软件压缩包怎么只有part1啊,part2在那里啊?
      

  4.   

    mshflexgrid.editable 属性改为鼠标和键盘都可以编辑
      

  5.   

    mshflexgrid有一个editable的属性??
    请看它所有e开头的属性
      

  6.   

    MSHFlexGrid1上放一个text文本框,单击单元格则文本框显示在单元格的上方。可以实现
    '************************************
    '*   名称:msgCondition_MouseDown
    '*   功能:
    '*   作者: zhzhufeng
    '*   参数:无
    '*   描述:
    '************************************
    Private Sub msgCondition_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim i, j As Integer
        With msgCondition
            txtInput.Visible = False
            If Button = 1 Then
                If .col = 1 Then
                    txtInput.Width = .CellWidth
                    txtInput.Left = .Left + .CellLeft
                    txtInput.Top = .Top + .CellTop
                    txtInput.Height = .CellHeight
                    txtInput.Text = .Text
                    txtInput.SelStart = 0
                    txtInput.SelLength = Len(txtInput.Text)
                    txtInput.Visible = True
                    txtInput.ZOrder
                    txtInput.SetFocus
                    .ZOrder 1
                End If
            End If
        End With
    End Sub
      

  7.   

    当然可以了,只不过要精心编写与TextBox相关事件的代码
    回车和四个方向键都可以支持
    充分利用Msflexgrid提供的各种事件,可以近乎完美地解决数据输入的问题
      

  8.   

    这个是很久前写的,对四个方向键的处理 
    说实在话,用MSflexgrid编辑数据,代码真的很繁琐Private Sub txtPrice_KeyDown(KeyCode As Integer, Shift As Integer)
        Dim Cancel As Boolean
        If KeyCode = vbKeyUp Or KeyCode = vbKeyDown Then
            Call txtPrice_Validate(Cancel)
            If Cancel Then
                KeyCode = 0
            End If
        End If
        With grdTrans
            Select Case KeyCode
                Case vbKeyUp
                    If .Row > 1 Then
                        If .Row = .TopRow Then
                            .TopRow = .Row - 1
                        End If
                        .Row = .Row - 1
                        .SetFocus
                        Call grdTrans_EnterCell
    '                    .SetFocus
                    End If
                    KeyCode = 0
                Case vbKeyDown
                    If .Row < .Rows - 2 Then
                        If Not .RowIsVisible(.Row + 1) Then
                            .TopRow = .TopRow + 1
                        End If
                        .Row = .Row + 1
                        .SetFocus
                        Call grdTrans_EnterCell
                    End If
                    
                    KeyCode = 0
                Case vbKeyLeft
                    If txtPrice.SelStart = 0 Then
                        Call txtPrice_Validate(Cancel)
                        If Not Cancel Then
                            .Col = .Col - 1
                            txtPrice.Visible = False
                            Call grdTrans_EnterCell
                        Else
                            KeyCode = 0
                        End If
                    End If
                Case vbKeyRight
                    If txtPrice.SelStart = Len(txtPrice.Text) Then
                        Call txtPrice_Validate(Cancel)
                        If Not Cancel Then
                            .Col = .Col + 1
                            grdTrans.SetFocus
                            txtPrice.Visible = False
                            Call grdTrans_EnterCell
                        Else
                            KeyCode = 0
                        End If
                    End If
                Case vbKeySpace
                    KeyCode = 0
    '''            Case vbKeyReturn
    '''                KeyCode = 0
            End Select
        End With
    End SubPrivate Sub txtPrice_KeyPress(KeyAscii As Integer)
            On Error Resume Next    If KeyAscii = 13 Then
            txtPrice.Text = AutoCalcPrice(txtPrice.Text)
            KeyAscii = 0
            SendKeys "{END}"
        ElseIf KeyAscii = 32 Then
            KeyAscii = 0
        End If
    End Sub