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




Answer this question

Wiew(get) result in text.Box from DataGridWiew

  • Kinnos

    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();



  • mehim

    Thanks for the reply POSKOK! I'm glad everything is working now!


  • bowie

    Thanks you very much!


  • SoCalChris

    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.


  • JackBriggs

    thanks very much, half problem is finished

  • reportman

    The code i send you personally and that works, can you post it here so other users can use it to

    Thanks in advance!


  • Oopier

    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


  • SamProsser

    Code:

    public void PrikaziRabat(int RedniBroj)
    {
    decimal SumaRabata = 0;

    foreach (DataRow row in ulazRobeDataSet1.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



  • ghostsoft

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

    thanks YOU PJ vdS :) again



  • Steve10

    sorry for my bad english :)

    can i send picture of my problem on your mail

    poskokpos@hotmail.com - my mail



  • Stevey

    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.


  • Wiew(get) result in text.Box from DataGridWiew