如何将信息从SQL数据库表绑定到Wrap Panel中的按钮 [英] How to bind information from SQL database table to button in Wrap Panel

查看:142
本文介绍了如何将信息从SQL数据库表绑定到Wrap Panel中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧我在WPF中创建一个EPOS系统而不是表格或WCF。



我创建了一个包含许多按钮的Wrap Panel,每个按钮代表一个某些产品(啤酒)...所以我有一个电晕按钮,desperado按钮,coors灯按钮等....



现在所有的按钮都是在Wrap Panel中。但是在单击按钮时,我希望将该产品添加到列表视图中。



我是否将每个按钮绑定到SQL数据库中的产品行,然后一旦单击它,列表视图中所需的信息就可以插入?



或者我还做别的什么?

Ok so im creating an EPOS system in WPF not forms or WCF.

I've created a Wrap Panel that has many buttons, each in which represent a certain product (beer)... So i have a corona button, desperado button, coors light button and so on....

Now all of the buttons are in the Wrap Panel. But upon the button being clicked i want that product to be added to a list view.

Do i bind each button to its product row within the SQL database and then once it is clicked the information that is needed in the list view can then just insert?

or do i do something else?

推荐答案

我认为你不能用它来解决它。净绑定行为。将控件绑定到数据库字段时,您将为控件的一个属性赋值。 (例如,标签的文字==> product_name)



你应该为每个Button_OnClick添加一个事件处理程序,所有按钮都可以共享同一个处理程序。



I don't think you can solve it using .net binding behaviour. When you bind a control to a database field, you're assigning a value to one property of the control. (Ex, a label's text ==> product_name)

You should add an event handler for each Button_OnClick, all buttons can share the same handler.

private System.Windows.Forms.Button button1;
this.button1 = new System.Windows.Forms.Button();
this.button1.Click += new System.EventHandler(this.button1_Click);

private void button1_Click(object sender, EventArgs e)
{
   // use this function to do something
}


这篇关于如何将信息从SQL数据库表绑定到Wrap Panel中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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