问题描述
嘿,伙计们,我的表单上有一个网格视图,只读=假,启用=真,这样我就可以在数据网格视图的单元格中选择文本的一部分。这可以正常工作,但当我有这样的设置时,也可以编辑文本,这是我不想要的部分。因此,我正在寻找一种解决方案,能够选择数据网格视图的单元格中的文本的一部分,但不允许用户编辑其中的值。
Advantage中的Tanx
推荐答案
dataGridView1.ReadOnly = false and dataGridView1.enabled = true
Private Sub dataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs)
If TypeOf e.Control Is TextBox Then
' Set the TextBoxCell to readonly
Dim textBoxCell As TextBox = DirectCast(e.Control, TextBox)
textBoxCell.[ReadOnly] = True
End If
End Sub