DataGridView中的文本框控件

编程入门 行业动态 更新时间:2024-10-26 14:34:04
本文介绍了DataGridView中的文本框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在Windows应用程序中的C#中正在处理datagridview。我想在DataGridView中添加文本框控件。所以,当我们运行它时,文本框应该显示在gridview中,我们可以在其中放置值,我的网格有3列,当我按下gridview的第3列的tab时,我想在网格中添加新行。

我该怎么做?

解决方案

问题缺乏细节和一般性,但要在 DataGridView 中获取文本框,您将要添加一些 DataGridViewTextBoxColumn 到 DataGridView 的列集合。这将导致它们在每行中都填充有文本框。

要检测用户在第3列上按下标签的时间,您可以添加1-2像素宽的第四列列,并使用 OnCellEnter 事件收到焦点(几乎绝对来自标签按键)。

好运气!

I am working on a datagridview in C# in windows application. I want to add textbox controls in DataGridView. So, when we run it then textbox should be shown in gridview and we can put value in it and My grid has 3 columns and I want to add new row in grid when I press tab on 3rd column of gridview.

How do I do this?

解决方案

It's hard to provide a precise answer since your question is lacking in detail and pretty general, but to get textboxes in your DataGridView, you're going to want to add some instances of DataGridViewTextBoxColumn to the DataGridView's Columns collection. This will cause them to be populated with textboxes in each row.

To detect when the user presses tab on the 3rd column, you can add a 1-2 pixel wide fourth column and detect that it has recieved focus (almost definitely from a tab keystroke) using the OnCellEnter event.

Good luck!

更多推荐

DataGridView中的文本框控件

本文发布于:2023-11-11 23:48:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579889.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   文本框   DataGridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!