datagridview文本框问题 [英] datagridview textbox issue

查看:67
本文介绍了datagridview文本框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想将文本框移到last在gridview的第一列中.当我尝试仅在gridview的第一列的lastrow中输入内容时,该文本框应该可见,并且输入的文本应该落在该文本框中.此外,我不想编辑从数据库中获取的记录,因此这就是为什么我将所有列都设为只读的原因.
请为我提供解决方案.

Hi,
I want to move the textbox to lastrow in first column of gridview. When I try to enter something only in lastrow in firstcolumn of gridview, the textbox should be visible and the entered text should fall on textbox. Moreover I don''t want to edit the records fetched from database so thats why I made all columns to read-only.

Please suggest me a solution.

推荐答案

您可以将虚拟记录添加为最后一条记录"
为此,请执行以下操作-删除数据绑定-使用DataTable或任何包含数据的容器-而不是直接读取器或数据库内容.
因为您只对只读模式感兴趣.

DataGridView.Rows.Add();之类的.

当显示正常时.
您可以在网格上强制执行非只读-然后在datagridview的单元格输入事件中选择自己的验证.

如果用户正在添加"文本的单元格-而行不是最大"-return;

否则,将文本添加到单元格/文本框中.

问候,
克里斯
You can add a dummy record as "last record"
todo so - remove the data bindings - use a DataTable or any container with your data - not a direct reader or something to the db.
as you are only interested in read-only mode.

DataGridView.Rows.Add(); or something.

When The display looks a-ok.
You can enforce a non-readonly on the grid - then select your own validation on cell enter event of the datagridview.

if the cell the user is "adding" text - and the row is not "max" - return;

otherwise add the text to the cell / textbox.

Regards,
Chris


这篇关于datagridview文本框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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