Record Begin Edit Event

I want to enable a "Cancel Update/Add" button and Save button when a user makes any change to a record. Is there anyway to know when a user begins editing a record besides TextChanged and similiar events I have tried the RowChanged/ing of the Datatable and other events with no luck.

Thanks
Simmy


Answer this question

Record Begin Edit Event

  • Tihomir Ignatov

    Like I wrote in my "answer" post. Set the froms keypreview property to true. Then in the forms KeyDown, KeyPress events and in any combobox SelectedIndexChanged events enable the buttons or call a function that enables the buttons.

    Hope this helps!
    Simmy

  • troy anderson

    Hi Simmy7. Just wondering. Can you show me how you did this Cuz, I want to implement the same functionality and don't know how to do it. What I want is to be able to enable and disable several control conponents in my form (save button, cancel button, a selection treeview, etc) as soon as the user starts modifying data in the controls. Controls that will trigger this can be a textbox, datagridview or combobox.

    Please let me know, I've posted this inquiry in several forums but not getting any response.

    Thank you.

    Rick..

  • Mark q jones

  • Lisha

    Finally figured it out. Set KeyPreview to true and then in the forms KeyPress enable the button when the activecontrol is one of the databound controls.

  • rfreire

    "the following will return true when a row has been edited:
    CType(_CM.Current, DataRowView).Row.HasVersion(DataRowVersion.Proposed)"

    That doesn't trigger an event does it

  • clevershark

    wrap all of your state changes to those controls in methods, to set the form state in one call.

    In the event handlers for the controls that can change the form state, call that state setting method.
    Events you will be interested in:
    TextBox - TextChanged or Validating
    ComboBox - TextChanged, SelectedIndexChanged, or Validating
    DataGridView - CurrentCellDirtyStateChanged


  • Scott Conrad

    Ok that was helpful but I am new to .Net and am still learning it after years with VB 6 and before. In that post it you gave a way to check the datarow state, is there any event that is raised when the datarow state changes Something to do with the currency manager Or do I need to use a timer to check Any code or ideas greatly appreciated!

    Simmy

  • Nasyua

    Sorry, I misunderstood your second post. So it is clear how to check if a record has been changed without having to call EndEdit() or EndCurrentEdit(), but I don't know what event gets fired when the change occur. Maybe someone else will respond.

  • StanoB

    Judge Dregg wrote:

    "But I think I've found a way. The documentation on DataRowVersion says:
    After invoking BeginEdit on a DataRow, any edited value becomes the Proposed value. Until either CancelEdit or EndEdit is invoked, the row has an Original and a Proposed version.

    So given that BeginEdit is implicitly called somewhere along the way, the following will return true when a row has been edited:
    CType(_CM.Current, DataRowView).Row.HasVersion(DataRowVersion.Proposed)"



  • Record Begin Edit Event