在vb中可以根据输入设定表格的行数和列数的控件,表格不与数据库相连,单独对表格中各单元格的值进行手动的输入和更改,并能获得这些值。本人是vb新手,望各位高手指点!

解决方案 »

  1.   

    看看这个:http://www.grid2000.com/cn/index.html
      

  2.   

    呵呵,楼上大哥开发的FlexGrid控件相当不错!不过对楼主的要求,用一个MSFlexGrid和一个textbox就可以实现啊!
      

  3.   

    MSFlexGrid可以实现你的要求
    属性rows设置总行数
    cols设置总列数
    row设置单元格的当前行
    col设置单元格的当前列
    text设置单元格的内容
      

  4.   

    msflexgrid加text不好還不如直接用mshflexgridflexgrid你安裝以後就會有demo直接可以看呀
      

  5.   

    在这里加入了一个text控件 下面的名为 textsl
    下面的cehflex 就是 mshflexgrid控件
    Private Sub TextSL_KeyDown(Key As Integer, Shift As Integer)
    With CeHFlex
    If Key = 38 Or Key = 40 Or Key = 37 Or Key = 39 Or Key = 9 Or Key = 13 Then
       Select Case Key  '查看键盘按下的是什么键
          Case 37        '向左方向键
            .TextMatrix(.Row, .Col) = TextSL
            If .Col > 1 And TextSL.SelStart = 0 Then
               .Col = .Col - 1
            End If
          Case 39         '向右方向键
            .TextMatrix(.Row, .Col) = TextSL
            If .Col < .Cols - 1 And TextSL.SelStart = Len(TextSL.Text) Then
               .Col = .Col + 1
            End If
          Case 9          'TAB 键
            .TextMatrix(.Row, .Col) = TextSL
            If .Col < .Cols - 1 Then
               .Col = .Col + 1
            End If
          Case 13         'Enter 键
            .TextMatrix(.Row, .Col) = TextSL
            If .TextMatrix(1, 1) <> "" Then
               Call FindTM
               If RstN.RecordCount < 1 Then
                  RstN.AddNew
                  CeHFlex.Enabled = True
                  TextSL.Visible = False
                  RstN!品名.Value = CeHFlex.TextMatrix(CeHFlex.Row, 1)
                  RstN!规格.Value = CeHFlex.TextMatrix(CeHFlex.Row, 2)
                  RstN!单位.Value = CeHFlex.TextMatrix(CeHFlex.Row, 3)
                  RstN.Update
                  RstN.Close
                  Set RstN = Nothing
                  Call RstNOpen(BName)
               Else
                  MsgBox "数据己经存在!", 16
               End If
            Else
               MsgBox "品名不能为空!", 16
            End If
       End Select
       TextSL.Text = .Text
       TextSL.Move .CellLeft + .Left - 10, .CellTop + .Top - 10, .CellWidth, .CellHeight
    End If
    End With
    End Sub
    Private Sub TextSL_KeyPress(KeyAscii As Integer) '用途:去掉按下TAB和Enter时的声音。
     If KeyAscii = &H9 Or KeyAscii = 13 Then
        KeyAscii = 0
     End If
    End Sub