Click here to Skip to main content
15,904,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to subtract value in datagridview in form1 and textbox from form2, and the result will change the value in datagridview in form 1 using C#

Datagridview name = prlist
Column = Quantity
textbox = txtqty
button = btnsub

What I have tried:

i havent tried yet im a begginer at c#
Posted
Updated 3-Mar-18 8:54am

1 solution

That depends on exactly what you are doing.
If you use Form2 in the same way you use a message box, or a FieOpenDialog but with an input then it's easy:
1) Add a property to Form2 which collects the value from the textbox and converts it to a number before returning it.
2) Then just get it:
C#
Form2 f2 = new Form2(0);
if (f2.ShowDialog() == DialogResult.OK)
   {
   int value = f2.Value;
   ...
   }


If you want to do anything else, it gets more complex, but these will either help or confuse you:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
 
Share this answer
 

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