Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Wiew(get) result in text.Box from DataGridWiew
 

Wiew(get) result in text.Box from DataGridWiew

How wiew result from dataGrid( sum of one collumn and get it in one textBox)

-example: sum of xlx Column and i will this sum show in a textBOX

POSKOK  Thursday, March 30, 2006 7:01 AM
The code i send you personally and that works, can you post it here so other users can use it to?

Thanks in advance!
Pieter Joost van de Sande  Friday, March 31, 2006 1:39 PM

DataSet dataSet = (DataGrid)grid.DataSource;
DataTable table = dataSet[ grid.DataMember ];

double total = 0;

foreach( DataRow row in table.Rows )
{
total += Convert.ToDouble( row[ "MyColumnToCount" ] );
}


txtTotal.Text = total.ToString();

POSKOK  Friday, March 31, 2006 1:43 PM
Code:

publicvoidPrikaziRabat(intRedniBroj)
{
decimalSumaRabata=0;

foreach(DataRowrowinulazRobeDataSet1.UlazArtikala)
{
if((int)row["RedniBroj"]==RedniBroj)
{
SumaRabata+=Convert.ToDecimal(row["IznosRabata"]);
}
}

iznosRabataTextBox.Text=SumaRabata.ToString();
}


call method

Code:

PrikaziRabat(int.Parse(brojRacunaTextBox.Text));
It work now :) - this is what i want

POSKOK  Wednesday, April 12, 2006 6:49 AM
You want to add functionality to your DataGrid that users can enter a Sum and you view the Sum-results somewhere?

I don't really understand your question.
Pieter Joost van de Sande  Thursday, March 30, 2006 8:21 AM

sorry for my bad english :)

can i send picture of my problem on your mail???

poskokpos@hotmail.com- my mail

POSKOK  Thursday, March 30, 2006 12:59 PM
Please try the forum first, please post a picture of your problem here. So i, but olso other users can help and when it is solved. Users with the same problem will find this thread with the search and there problem will be solved by only viewing this thread, so it helps other users to.

So, please try to solve this on the board first.
Pieter Joost van de Sande  Thursday, March 30, 2006 1:04 PM
I have received the screenshot, so i will post it here on the board:

Screenshot to indicate the problem

What do you want to enable in this Textbox?
You want users to type a Sum-expression there and your application will calculate this or do you want to display the total of all Iznos Rab. in the TextBox?
Pieter Joost van de Sande  Thursday, March 30, 2006 1:13 PM
thanks very much, half problem is finished
POSKOK  Friday, March 31, 2006 12:08 PM
The code i send you personally and that works, can you post it here so other users can use it to?

Thanks in advance!
Pieter Joost van de Sande  Friday, March 31, 2006 1:39 PM

DataSet dataSet = (DataGrid)grid.DataSource;
DataTable table = dataSet[ grid.DataMember ];

double total = 0;

foreach( DataRow row in table.Rows )
{
total += Convert.ToDouble( row[ "MyColumnToCount" ] );
}


txtTotal.Text = total.ToString();

POSKOK  Friday, March 31, 2006 1:43 PM
Thanks you very much!
Pieter Joost van de Sande  Friday, March 31, 2006 1:45 PM
Code:

publicvoidPrikaziRabat(intRedniBroj)
{
decimalSumaRabata=0;

foreach(DataRowrowinulazRobeDataSet1.UlazArtikala)
{
if((int)row["RedniBroj"]==RedniBroj)
{
SumaRabata+=Convert.ToDecimal(row["IznosRabata"]);
}
}

iznosRabataTextBox.Text=SumaRabata.ToString();
}


call method

Code:

PrikaziRabat(int.Parse(brojRacunaTextBox.Text));
It work now :) - this is what i want

POSKOK  Wednesday, April 12, 2006 6:49 AM
Thanks for the reply POSKOK! I'm glad everything is working now!
Pieter Joost van de Sande  Wednesday, April 12, 2006 7:10 AM

PJ. van de Sande wrote:
Thanks for the reply POSKOK! I'm glad everything is working now!

thanks YOU PJ vdS :) again

POSKOK  Wednesday, April 12, 2006 7:21 AM

You can use google to search for other answers

Custom Search

More Threads

• Bindinglist findbykey datagridview backgroundworker
• Manipulating Datagridview cell borders
• Databind control with multiple tables
• SqlDataTime Overflow
• how to display report in datagrid
• c# How to use ComboBox independent Value to determine What to Display in DatagridView?
• transfer data between/to forms
• Force Databinding before the control gets into view
• Strongly-typed DataColumn change events
• selecting Columns from AS400 , modifying them for data format of SQL 2000/2005 exporting data to SQL Server 2000/2005