问题描述
是否存在将允许但不允许在datagridview中进行编辑的属性(或解决方法),但还允许突出显示单元格中的文本?
Is there a property (or workaround) that will but not allow editing in a datagridview BUT also allow for the highlighting of text in cells?
当前用户能够突出显示/复制和编辑单元格中的文本(但未进行任何更改)。他们尝试在单元格中编辑文本,然后在不保存更改时感到困惑。我想要它,因此单元格不会显示为可编辑的。
Currently users are able to highlight/copy and edit text in cells (but no changes are being made). They attempt to edit the text in cells and then become confused when their changes are not being saved. I want it so the cells do not appear editable.
我尝试将readonly属性设置为true,但这会禁用单元格上文本的突出显示。我希望他们能够从单元中复制。是否有类似readonly = true的属性仍允许突出显示单元格?
I tried setting the readonly property = true, but that disables highlighting of text on the cell. I want them to be able to copy from the cells. Is there a property like readonly = true that still allows for highlighting of cells?
编辑-为了澄清:
文本框具有我正在寻找的效果:我有一个文本框字段,其初始文本为readonly = true。我可以使用鼠标突出显示该文本框中的部分文本(然后将其复制)。文本框的内容不可编辑。这是我想要的效果,但是我想使用fullrowselectmode中的datagridview来做到这一点。
The textbox has the effect I am looking for: I have a textbox field with initial text with readonly = true. I can use my mouse to highlight parts of the text in that textbox (and then copy it). The contents of the textbox is not editable. This is the effect I want, but I want to do this with the datagridview in fullrowselectmode.
当前,我有:
selectionMode = fullRowSelect(我想成为能够选择整行,而不是按单元格)
Currently I have:selectionMode = fullRowSelect (I want to be able to select an entire row, not by cell)
readOnly = False
readOnly = False
EditMode = EditOnKeystrokeOrF2
EditMode = EditOnKeystrokeOrF2
这些设置允许用户双击单元格,然后突出显示任何单元格中的文本。这是我想要的效果,但是这些设置的唯一问题是用户还可以在该单元格中键入更多/删除文本。
These settings allow users to "double click" on a cell and then highlight text within any cell. This is the effect I want, BUT the only problem with these settings is users can also type more/delete text in that cell.
谢谢!
推荐答案
您应设置自己的readonly属性DataGridView设置为true,则在用户可以复制单元格时将无法对其进行编辑。
You should set the readonly property of your DataGridView to true, then it will not be editable while users can copy the cells.
这篇关于禁用对datagridview的编辑,但仍允许突出显示以复制和粘贴单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!