0

I am designing a product table in which I have the following columns:

Product Name (label) | Quantity (numericUpDown) | Price (Label)

My question is how to add table rows with the product infos and controls and how to bind the controls for quantity to change the price based on the quantity?

I tried using datagridview but I need to set a maximum value to the quantity (based on a database value).

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • The Labels seem unnecessary, the standard Text EditStyle should do. For a NumUpDown see [here](http://stackoverflow.com/questions/18145522/how-to-create-datagridview-numericupdown-column). Not exactly very simple, though.. Also: You'll need a price __and__ a total field somewhere. You can use the `CellValueChanged` event to calculate the total. – TaW Jul 29 '14 at 19:53

1 Answers1

0

Nevermind i fixed it myself!

for further references, if building a custom table using table layout and asigning controls in a multidimensional list/collection/dictionary/etc, when assigning an event handler based on the index be shure to move the index into a new variable first because the event handler sets a pointer instead of the actual value of the index at the specific loop,

example pseudocode:

for(int i = 0; i<10; i++) {

int index = i; // prevent referencing to the pointer

// components code here

//event handler example: TextBox.Click += (sender, args) => customMethodToHanldeInteractionBetweenCmponents(index);

TableLayout.Controls.Add(TextBox);

}