I have a databound datagridview. When clicked, a second databound datagridview loads AND the numbers within the columns of this second datagridview are mulptiplied by 60. The problem is that when I click on the first datagridview a second, third etc time, the numbers are multiplied by 60 every time. I don't want this to happen. I tried this:
private Boolean _alreadyBeenMultiplied;
public Boolean AlreadyBeenMultiplied
{
get { return _alreadyBeenMultiplied; }
set
{
_alreadyBeenMultiplied = false;
}
}
private void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
double hrsToMins=(double.Parse(dgv.Rows[e.RowIndex].Cells["Hours"].Value.ToString())*60);
if(_alreadyBeenMultiplied == false)
{
if (dgv.Columns[e.ColumnIndex].Name == "Hours")
{
if (dgv.Rows[e.RowIndex].Cells["Hours"].Value.ToString() != "0")
{
e.Value = Double.Parse(e.Value.ToString()) * 60;
e.Value = (double.Parse(e.Value.ToString()));
_alreadyBeenMultiplied = true;
}
}
}
}
What happens is that when I click the first dgv the second time, the numbers all get divided by 60, returning to their original values. Also, the other columns involved in this code (I only showed the "Hours" column here for simplicity) are not effected at all, not even on initial click. If anyone can help, I would really appreciate it. I'm almost positive it's a logic problem.