先说谢谢了!

解决方案 »

  1.   

    参考:
    Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
        If DataGrid1.Col <> 2 Then Exit Sub  '限制第3列的数据为(-,X,*)
        If KeyAscii = 8 Then Exit Sub
        If KeyAscii <> Asc("-") And KeyAscii <> Asc("X") And KeyAscii <> Asc("*") Then
            KeyAscii = 0
        End If
    End Sub
      

  2.   

    如果限制那个字段只能输入一个字符,可以这样写 :Private Sub DataGrid1_KeyPress(KeyAscii As Integer)
        If DataGrid1.Col <> 2 Then Exit Sub '限制第3列的数据为(-,X,*)
        If KeyAscii = 8 Then Exit Sub
        If Len(DataGrid1.Text) > 0 And DataGrid1.SelLength = 0 Then '限制只能输入一个字符
            KeyAscii = 0
            Exit Sub
        End If
        If KeyAscii <> Asc("-") And KeyAscii <> Asc("X") And KeyAscii <> Asc("*") Then
            KeyAscii = 0
        End If
    End Sub
      

  3.   

    谢绝faysky2,但我想,在修改的时候能不能给他一个下拉列表框,而列表框中只有这三个字符?
      

  4.   

    用listBox来组合吧,看看这里有没有用:
    http://www.hosp.ncku.edu.tw/~cww/html/q00184.html