DataGridView中的文本框控件 [英] Textbox control in DataGridView

查看:153
本文介绍了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中的文本框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆