Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Suppress an Event

Suppress an Event

Scheduled Pinned Locked Moved C#
cssdebugging
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zaboboa
    wrote on last edited by
    #1

    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!

    P 1 Reply Last reply
    0
    • Z zaboboa

      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!

      P Offline
      P Offline
      Pradyumna Gogte
      wrote on last edited by
      #2

      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

      A Z 2 Replies Last reply
      0
      • P Pradyumna Gogte

        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

        A Offline
        A Offline
        Alomgir Miah
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • P Pradyumna Gogte

          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

          Z Offline
          Z Offline
          zaboboa
          wrote on last edited by
          #4

          Thank you. That's excactly what I am doing, is to keep a flag.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups