Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

C# comparing Values Rows.Cell Winform, Excel Import

$
0
0

I have a Winform that i import an Excel sheet to a datagrid. I am needing to do a comparison of 2 columns and a static value.

Example

If column (F) is greater than static value Z4=(48) then return 48 in column (V1) if less than return column value(G) to column (V1).

The code below will do the greater than part, how would i add the part if its less than?

 

decimal F = Convert.ToDecimal(dataGridView1.Rows[i].Cells[5].Value ?? 0);
                    var Z4 = 48;
                    Math.Max(F, Z4);
                    var V1 = Math.Max(F, Z4);
                    dataGridView1.Rows[i].Cells[8].Value = V1;

// I need to add this

decimal G = Convert.ToDecimal(dataGridView1.Rows[i].Cells[6].Value ?? 0);



Booney440




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>