MSFLEXGRID控件里,想在单元格里输入数据,而且要求是:在第二行第一列的位置开始,能够输入数据,输入之后还要求判断回车键有没有按下,如果按下了,就表明这个内容填写了,根据填写的内容然后同一行里其他单元格里填充内容,最后一行填完整了,再换到第二行。麻烦各位了。 -------------------------------------------------------------------------------- 一段利用MsFlexGrid控件作的非常简单的程序,可以输入英文字符和数字,按回车自动右移,支持方向键,可以自动添加行。只用到一个MsFlexGrid控件,没有别的: Private Sub Form_Load() Grid1.Rows = 10 Grid1.Cols = 6 End Sub Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) Dim X As Long Dim Y As Long Dim L As Long Dim Tmp As String X = Grid1.Col Y = Grid1.Row Select Case KeyCode Case 13 X = X + 1 If X >= Grid1.Cols Then X = 1 Y = Y + 1 If Y >= Grid1.Rows Then Grid1.Rows = Grid1.Rows + 1 End If Grid1.Col = X Grid1.Row = Y Case 8 Tmp = Grid1.Text L = Len(Tmp) - 1 If L > -1 Then Grid1.Text = Left(Tmp, L) Case Else Grid1.Text = Grid1.Text & Chr(KeyCode) End Select End Sub 或者 private sub Grid_click() text1.move grid.cellleft+grid.left,grid.top+grid.celltop,grid.cellwidth-30,grid.cellheight-30 text1.zorder 0 end sub private sub text1_keypress(keyacii as integer) if keyascii=13 then grid.text=text1.text text1.visible=false end if end sub

评论