我用VsFlexGrid控件显示数据,想实现表格中的某几列能进行编辑,其余记录不能编辑,如何实现,我在它的属性找到editable属性,可它只是把所有表格的所有列都能编辑。如何控制某列?

解决方案 »

  1.   

    Option ExplicitPrivate Sub Form_Load()
        Text1.BorderStyle = 0
        Text1.Visible = False
    End SubPrivate Sub MSFlexGrid1_Click()
        With MSFlexGrid1
            If .Col <> 2 Then Exit Sub '只能编辑第二列
            Text1.Visible = True
            Text1.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth, .CellHeight
            Text1.Text = .Text
            Text1.SetFocus
        End With
    End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 13 Then
            MSFlexGrid1.Text = Text1.Text
            Text1.Visible = False
            MSFlexGrid1.SetFocus
        End If
    End Sub
      

  2.   

    不是啊,我用的是VsFlex控件,不是MsflexGrid控件啊!用VsFlexgrid控件的属性列就能编辑啊
      

  3.   

    Private Sub vfg_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
        If col= 0 Then Cancel = True '将第一列设为不可编辑
    End Sub