如何将用户输入的值从文本框和组合框绑定到Wpf中的Datagrid [英] How to bind user entered values from textbox and combobox to Datagrid in Wpf
本文介绍了如何将用户输入的值从文本框和组合框绑定到Wpf中的Datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将用户输入的值从文本框和组合框插入到Datagrid
当我们单击一个按钮时?
在线上是否有示例?显示在ComboBox
中. datagrid/listview/任何控件都绑定到ObservableCollection<SomeItemType>
.
当用户点击添加按钮时,将使用文本框/组合框中的数据创建一个新的SomeItemType
实例,并将其添加到ObservableCollection<>
中.这将自动更新视图(无论您在此处使用什么视图).
希望您知道数据集吗?
if(ans ==是)
{
那么没什么大不了的,只需将文本框或组合框的文本插入到DataSet的某个单元格中即可.
将数据集表分配给DataGrid.DataSource
}
其他
只需发送一条消息,我就会用DataSet的实例来回复您
How to insert user entered values from textbox and combobox to Datagrid
when we click a button?
Is there any example online?
解决方案
Typically, you bind theTextBox
to a string variable and theComboBox
selected item to a varable of the type of item displayed in theComboBox
. The datagrid/listview/whatever control is bound to anObservableCollection<SomeItemType>
.
When the user hits an Add button, a newSomeItemType
instance is created using the data from the textbox/combobox, and is added to theObservableCollection<>
. This will automatically update the view (whatever it is that you use there).
hope u know the DataSets?
if(ans==Yes)
{
then its not a big deal, just insert the text of textbox or combobox in some cell of DataSet
Assign the DataSet Table to DataGrid.DataSource
}
else
Just Drop a Message, i wil get back to You with Exapmle of DataSet
这篇关于如何将用户输入的值从文本框和组合框绑定到Wpf中的Datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文