从SQL Server检索数据到WPF中的文本框 [英] retrieve data from sql server to textboxes in wpf
本文介绍了从SQL Server检索数据到WPF中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在winform应用程序中有此代码,用于从sql server中检索数据以填充文本框
I have this code in winform application for retrieving data from sql server to fill textboxes
daPattern.SelectCommand = new SqlCommand("SELECT * from Pattern", cs);
dsPattern.Clear();
daPattern.Fill(dsPattern);
PatternBS.DataSource = dsPattern.Tables[0];
ID.DataBindings.Clear();
ID.DataBindings.Add(new Binding("Text", PatternBS, "ID"));
ID是绑定到表Pattern中的列ID的文本框,我想在wpf代码中绑定文本框,但DataBindings在那里不起作用,所以基本上我只需要热的帮助来编写代码即可在wpf
ID is textbox that is binded to column ID in table Pattern, and I want to bind textbox in wpf code but DataBindings doesnt work there, so basically I just need help on hot to write code to bind textboxes in wpf
推荐答案
听起来更新鲜.请查看 WPF数据绑定 [^ ]
Sounds like fresher.Have a look on WPF Data Binding [^]
WPF与Windows窗体的不同之处在于,UI端的数据绑定变得非常重要.
您可以从数据绑定(WPF)开始 [一次迁移到WPF数据绑定一步 [ ^ ]对于理解数据绑定非常有用.
数据绑定概述 [ ^ ]也可以帮助您入门.
WPF is different from Windows Forms in the sense that Data Binding on the UI side gains a lot of importance.
You can start with Data Binding (WPF)[^] to help you learn more about this topic.
Moving Toward WPF Data Binding One Step at a Time[^] is very useful to understand data binding.
A databinding overview[^] can also help you get started.
这篇关于从SQL Server检索数据到WPF中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文