嘿,我的表格上有一个gridview,withonly = false and enabled = true,这样我就可以在datagridview的单元格中选择文本的一部分。这可以正常工作,但是当我有这样的设置时,也可以编辑文本,那就是我不关心的部分。
因此,我正在寻找一个解决方案,以便能够在数据杂志的单元格中选择文本的一部分,但不允许用户编辑其中的值。
优势中的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