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. Detect if any control in a form has changed

Detect if any control in a form has changed

Scheduled Pinned Locked Moved C#
question
3 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.
  • B Offline
    B Offline
    Braulio Dez
    wrote on last edited by
    #1

    Hi, I have several controls in my form ( a tab form... that includes combos, edit boxes, grids, ...).... Is there a way to know if any of this control has changed, just to change the flag and save changes ? ( I know that I could go control by control .... but is there a more generic way ?). Thanks, greetings Braulio

    K 1 Reply Last reply
    0
    • B Braulio Dez

      Hi, I have several controls in my form ( a tab form... that includes combos, edit boxes, grids, ...).... Is there a way to know if any of this control has changed, just to change the flag and save changes ? ( I know that I could go control by control .... but is there a more generic way ?). Thanks, greetings Braulio

      K Offline
      K Offline
      krisp
      wrote on last edited by
      #2

      If I understand what you are doing, then just use events with event handlers. All components have events for changes and stuff, for example the TextBox has a TextChangedEvent. In your form you can just add it to listen for this event. Using properties panel on the form design just click the events button (little lightning bolt above the panel of properties) and get a list of events for the Textbox you have slected, look for TextChanged or TextChanging, and double click that field. It will add a new Event handler in your form code, and you can do what ever in that method. It is the exact same as a button1_Click( object sender, MouseEventArgs e ) that you most likely have probably used before. All otehr controls have events as well, ComoboBox.SelectedChanged I think as well.

      L 1 Reply Last reply
      0
      • K krisp

        If I understand what you are doing, then just use events with event handlers. All components have events for changes and stuff, for example the TextBox has a TextChangedEvent. In your form you can just add it to listen for this event. Using properties panel on the form design just click the events button (little lightning bolt above the panel of properties) and get a list of events for the Textbox you have slected, look for TextChanged or TextChanging, and double click that field. It will add a new Event handler in your form code, and you can do what ever in that method. It is the exact same as a button1_Click( object sender, MouseEventArgs e ) that you most likely have probably used before. All otehr controls have events as well, ComoboBox.SelectedChanged I think as well.

        L Offline
        L Offline
        Lee Nowotny
        wrote on last edited by
        #3

        Furthermore, if you only care about whether a control changed, you can assign the same event handler to all the "change" events of the controls on the form. Then, if you need to do more, you could use the sender object to do extra things (besides just determining if a control changed). You would just need a generic event handler in the form: ControlChanged( object sender, EventArgs e ) "Shut up brain, or I'll stab you with a QTip!" - Homer Simpson

        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