Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 5-Mar-15 1:31am
v2

1 solution

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.

C#
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
}
 
Share this answer
 
Comments
[no name] 5-Mar-15 7:23am    
I'm using WPF, and yes im guessing that on_click of every button it would add to this listView but im not sure how to do that.
Joan Magnet 5-Mar-15 7:30am    
you've not mentioned WPF in your question.

this is for winform but you can use it for WPF, add Click event in your button definition.

<Button Click="button1_Click"/> (or the name you choose)


A sample:

http://www.dotnetperls.com/button-wpf

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900