Suppress an Event
-
Hello, Is there a way of suppressing ColumnChanged event, when I am adding a new row like this:
Debug.WriteLine("Adding new row"); DataRow rowName = this.dataset.Tables["Stages"].NewRow(); this.textBoxTotalUnits.Text = totalUnits; // Populate Grid System.DateTime dt = System.DateTime.Now; rowName["StageNumber"] = 1; rowName["NumUnits"] = Convert.ToInt32(totalUnits); rowName["MonthsToService"] = 5; rowName["RegistrationDate"] = dt; rowName["AvgAbsorptionPerMonth"] = 7; double remainder = Math.IEEERemainder(Convert.ToInt32(totalUnits), 7); if (remainder == 0) { rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7); } else { rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7)+1; } this.dataset.Tables["Stages"].Rows.Add(rowName);
Thank you! -
Hello, Is there a way of suppressing ColumnChanged event, when I am adding a new row like this:
Debug.WriteLine("Adding new row"); DataRow rowName = this.dataset.Tables["Stages"].NewRow(); this.textBoxTotalUnits.Text = totalUnits; // Populate Grid System.DateTime dt = System.DateTime.Now; rowName["StageNumber"] = 1; rowName["NumUnits"] = Convert.ToInt32(totalUnits); rowName["MonthsToService"] = 5; rowName["RegistrationDate"] = dt; rowName["AvgAbsorptionPerMonth"] = 7; double remainder = Math.IEEERemainder(Convert.ToInt32(totalUnits), 7); if (remainder == 0) { rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7); } else { rowName["TotalMonthsAbsorption"] = Math.Floor(Convert.ToInt32(totalUnits)/7)+1; } this.dataset.Tables["Stages"].Rows.Add(rowName);
Thank you!zaboboa, Well there is no quick and easy way to do this. However you can do this in two ways. Events on a control are hooked to your function in initialization phase through a simple += statement. before you execute your code you could un hook the event handler add the row and then hook the event handler back in. this is a rather crude way to handle this. the other option is maintain a flag in your code. when adding the row before adding the row set the flag. check this in the columnchanged event handler. if it is set then ignore the event. after the row is added reset this flag. Hope this helps... Prady
-
zaboboa, Well there is no quick and easy way to do this. However you can do this in two ways. Events on a control are hooked to your function in initialization phase through a simple += statement. before you execute your code you could un hook the event handler add the row and then hook the event handler back in. this is a rather crude way to handle this. the other option is maintain a flag in your code. when adding the row before adding the row set the flag. check this in the columnchanged event handler. if it is set then ignore the event. after the row is added reset this flag. Hope this helps... Prady
See the example this.dataGridTextBoxColumnExValue.TextBox.KeyPress -= new KeyPressEventHandler(this.TextBoxFloatValueKeyPress); //Do your stuff this.dataGridTextBoxColumnExValue.TextBox.KeyPress += new KeyPressEventHandler(this.TextBoxFloatValueKeyPress); Live Life King Size Alomgir Miah
-
zaboboa, Well there is no quick and easy way to do this. However you can do this in two ways. Events on a control are hooked to your function in initialization phase through a simple += statement. before you execute your code you could un hook the event handler add the row and then hook the event handler back in. this is a rather crude way to handle this. the other option is maintain a flag in your code. when adding the row before adding the row set the flag. check this in the columnchanged event handler. if it is set then ignore the event. after the row is added reset this flag. Hope this helps... Prady