阻止文本在 DataGridViewTextBoxCell 中突出显示/覆盖

发布于 2024-10-08 18:34:35 字数 297 浏览 0 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十六岁半 2024-10-15 18:34:35

您可以捕获 CellClick 事件,然后调用 dataGridView1->BeginEdit(false) 开始编辑单元格,而不突出显示内容。
然而,这不是一个完美的答案,因为这会将插入符号放在内容的末尾,而不是按下鼠标的位置。

You can catch the CellClick event and then call dataGridView1->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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文