相应地点击一个按钮后如何在datagridview中检索一行. [英] how to retrieve a single row into datagridview after tapping a button accordingly.

查看:103
本文介绍了相应地点击一个按钮后如何在datagridview中检索一行.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生您好,
我正在使用Winform C#在VS中工作,我创建了三个文本框和两个按钮.将显示一个名为插入"和下方"到该datagridview的按钮.
我想要的是,如果我在文本框中输入一些数据,然后点击插入"按钮.那么它的特定行就会根据那里的列插入.并且一旦我点击插入"按钮,就只能看到它的行.在datagridview中显示.

如果我将新数据输入到相同的文本框中,则与往常一样.它将在数据库中进行更新,并在datagridview中作为第二行显示.


我被卡住了,如何实现这个先生.

谢谢
PRADEEPCBZ

Hello sir,
Am working in VS using winform C#,thing is i had created three textbox,and two buttons.A button called "insert" and Below to that datagridview will be visible.
What i want is if i enter some data into textboxes and if i tap the "insert " button.Then its particular rows get to inserted acoording to there columns.And as soon as i tap the "insert" button,only its row as to be displayed in datagridview.

And if i enter the new data into the same textboxes ,then same as usual.It as to update in database and dispayed as second row in datagridview.


I got stuck ,how to achieve this sir.

Thanks
PRADEEPCBZ

推荐答案

不是将其插入GridView,而是需要插入容器.容器应实现INotifyCollectionChanged.一旦将新行添加到集合中,GridView应该会自动更新.
例如,有关如何完成此操作的示例,请搜索 ObservableCollection [ ObservableCollection [ ^ ]
Instead of inserting it into GridView you need to insert in into container. The container should implement INotifyCollectionChanged. GridView should update automatically once new row added to collection.
For example of how it should be done search for ObservableCollection[^] and binding to ObservableCollection[^]


这篇关于相应地点击一个按钮后如何在datagridview中检索一行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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