阻止文本在 DataGridViewTextBoxCell 中突出显示/覆盖
我正在开发一个 Windows 窗体应用程序,它使用 DataGridView 供用户输入一些数据。用户将数据输入到DataGridViewTextBoxCell
中。这工作正常,但是如果用户想要返回并编辑该数据,当用户开始编辑时,现有文本会自动被选择并覆盖。
我希望 DataGridViewTextBoxCell 的行为更像常规的 TextBox 控件。我希望用户能够简单地将克拉插入到他们已经输入文本的 DataGridViewTextBoxCell 中的任何位置,然后开始编辑,而不覆盖任何现有文本。
有什么建议吗?
I am developing a Windows Forms application that uses a DataGridView
for a user to enter some data. The user enters the data into a DataGridViewTextBoxCell
. This works fine, however if the user wants to go back and edit that data, the existing text there automatically gets selected and overwritten when the user starts editing.
I would like the DataGridViewTextBoxCell
to behave more like a regular TextBox
control. I want the user to simply be able to insert the carat anywhere in a DataGridViewTextBoxCell
they have already entered text into, and then start editing without any existing text being overwritten.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以捕获
CellClick
事件,然后调用dataGridView1->BeginEdit(false)
开始编辑单元格,而不突出显示内容。然而,这不是一个完美的答案,因为这会将插入符号放在内容的末尾,而不是按下鼠标的位置。
You can catch the
CellClick
event and then calldataGridView1->BeginEdit(false)
to start editing the cell without highlighting the content.However, this is not a perfect answer as this will place the caret at the end of the content and not where the mouse was pressed.