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

VulpesRank #55 · 29.2K reputationPosted Nov 22, 2014, 12:43 PM EST
Try this:
Mfwamba Tshimanga155 reputationPosted Nov 23, 2014, 10:24 PM EST
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...
VulpesRank #55 · 29.2K reputationPosted Nov 24, 2014, 5:37 AM EST
Mfwamba Tshimanga155 reputationPosted Nov 25, 2014, 10:02 AM EST
VulpesRank #55 · 29.2K reputationPosted Nov 25, 2014, 11:57 AM EST
Mfwamba Tshimanga155 reputationPosted Dec 2, 2014, 3:22 AM EST
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();
}
VulpesRank #55 · 29.2K reputationPosted Dec 2, 2014, 4:08 AM EST
Mfwamba Tshimanga155 reputationPosted Dec 2, 2014, 5:29 AM EST
Now have a look please how I do insert new row:
VulpesRank #55 · 29.2K reputationPosted Dec 2, 2014, 6:14 AM EST
Mfwamba Tshimanga155 reputationPosted Dec 16, 2014, 1:27 PM EST
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: