Click here to Skip to main content
15,070,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datagridview that has a percentage symbol in the cell. I need to convert to a percentage before calculating. The data looks like 17% and I need it to look like 0.17.

What I have tried:

string cellValue;
              cellValue = dataGridView1.Rows[i].Cells[17].Value.ToString(); // % Cycle Remaining
              cellValue = cellValue.Replace("%", "");
              dataGridView1.Rows[i].Cells[17].Value = cellValue ;  // % Cycle Remaining


              int a = Int32.Parse(tb_OrderCycle.Text);
              int b = Convert.ToInt32(dataGridView1.Rows[i].Cells[17].Value);  // % Cycle Remaining
              int C = a * b ;
              dataGridView1.Rows[i].Cells[32].Value = C; //Min. into Cycle
Posted
Updated 5-Jul-20 6:15am

1 solution

Converting a percentage number to its actual value is just a matter of dividing by 100.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900