Hi!
I wrote theses codes to make a sum Datagrid column and showing the total in a textbox.
Its works smootly. But its doesnt work dynamically. The total happear in time when I close and reopen it. Then how can I make this total showing dynamically on time.
Please have a look on my codes:
private void Bill_Activated(object sender, EventArgs e)
{
int sum = 0;
for (int i = 0; i < dataGridView2.Rows.Count; ++i)
{
sum += Convert.ToInt32(dataGridView2.Rows[i].Cells[9].Value);
totalbill.Text = " " + sum.ToString();
}
Loading
Mfwamba TshimangaPosted Dec 16, 2014, 6:27 PM
Let coming back to our last question. Let's me please explain to you in another way to give to you a good understanding:
I write this code and drop it to show you that each time when I save my records. What happen?
the datagrid "breath" and actualize in real time. This is the way I need for my textboxbox.
Then the codes I need to be resolved is this and I putted also in Activated event. But nothing happen:
VulpesPosted Dec 2, 2014, 11:14 AM
Mfwamba TshimangaPosted Dec 2, 2014, 10:29 AM
Now have a look please how I do insert new row:
VulpesPosted Dec 2, 2014, 9:08 AM
Mfwamba TshimangaPosted Dec 2, 2014, 8:22 AM
Let's doing it very slowly. I mean my explanation are not been well transmited.
1. Since now all the codes you sent are working perfectly (unfortenatly still not my purpose)
2. The problem is not calculation (just to make the textbox dynamic)
3 when I say make it dynamic I am not talking about calculation (for instance: 1+1 = 2). I refer to sumation of my datagrid. Because when you read well the code I sent the first time you will realize that its concerning datagrid sumation. Then this final result appear in the textbox... Not all! Why? because each time when I insert new record the final result doesnt be actualize itself on that textbox in real time (ONLY when you restard the problem. That's WRONG).
4. my target it's not on calculation. Because its already working well. The problem is to avoid to close/open the form or the program to see the textbox actualize the final result.
Vulpe, this is the first codes I do send:
private void Bill_Activated(object sender, EventArgs e)
{
int sum = 0;
for (int i = 0; i < dataGridView2.Rows.Count; ++i)
{
sum += Convert.ToInt32(dataGridView2.Rows[i].Cells[9].Value);
totalbill.Text = " " + sum.ToString();
}
VulpesPosted Nov 25, 2014, 4:57 PM
Mfwamba TshimangaPosted Nov 25, 2014, 3:02 PM
VulpesPosted Nov 24, 2014, 10:37 AM
Mfwamba TshimangaPosted Nov 24, 2014, 3:24 AM
I could say that I do use a button to have the result on a "Totalbill.Text". Mean that after inserting numbers in my textboxes when I click on the button its should give result on that textbox dynamilly. I do not use the datagrid. Sorry...
VulpesPosted Nov 22, 2014, 5:43 PM
Try this: