单击datagrid外部的按钮时如何将新行添加到datagrid(WPF工具包) [英] How to add a new row to a datagrid(WPF toolkit) when click on a button in the outside of datagrid

查看:110
本文介绍了单击datagrid外部的按钮时如何将新行添加到datagrid(WPF工具包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击数据网格外部的按钮时,我想在数据网格中添加新行.
该数据网格已与SQL Server数据库绑定,并且在运行时具有一些数据
我想通过数据库向数据库添加新数据

我尝试了很多,但是没有成功

有人回复我会对我有很大的帮助...

提前致谢..

I want to add a new row in the datagrid when click on a button in the outside of a datagrid.
The datagrid is bound with SQL Server database, and it have some data at runtime
I want to add new data to the database through the database

I tried a lot, but it was unsuccessful

Anyone reply me it will be very helpful for me...

Advance thanks..

推荐答案

在WPF中执行此操作的最佳方法是使数据源成为可观察的集合.然后,您可以将项目添加到集合中,并且网格将更新.当然,如果您拥有全部的SQL,则应将其添加到数据库中并刷新数据源.
The best way to do this in WPF is to make the data source an observable collection. Then you can add items to the collection and the grid will update. Of course, if you have SQL behind it all, you should add the item to the DB and refresh the data source.


这篇关于单击datagrid外部的按钮时如何将新行添加到datagrid(WPF工具包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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