c# datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajapavan
    New Member
    • Apr 2018
    • 2

    c# datagridview

    c# windows form application in the same dataGridView compare the two columns which column value is high then disply the message box
  • SampathTharanga
    New Member
    • Apr 2018
    • 4

    #2
    Hi rajapavan,
    Try like this code, I guess this code is helpfull for u.
    Code:
    int Value1=0, Value2=0;
    for (int row = 0; row < dataGridView1.Rows.Count; ++row)
    {
    Value1 = int.Parse(dataGridView1.Rows[row].Cells["Column1"].Value.ToString());
    Value2 = int.Parse(dataGridView1.Rows[row].Cells["Column2"].Value.ToString());
    
    if(Value1 > Value2)
        MessageBox.Show("Largest value is " + Value1);
    else
        MessageBox.Show("Largest value is " + Value2);
    }

    Comment

    Working...