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. Update data in Grid on form1 from form2.

Update data in Grid on form1 from form2.

Scheduled Pinned Locked Moved C#
csshelptutorialannouncement
2 Posts 2 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.
  • I Offline
    I Offline
    Inpreet Singh
    wrote on last edited by
    #1

    Hello, I am using Datagrid to show records and there are two buttons for Add new record and edit record. when add or edit button is clicked new form is opened where user enter data n after clicking ok on that form activation returns to datagrid form. Now the problem is, I want to execute UpdateGrid() method which shows updated data into grid. This can be called on Activated event of the form but if that form is MDI child Activated event does not work. so after editing or add new record I don't have any event to raise to update data into grid. If I don't make grid form as MDI child Activated event work properly but that doesn't fullfill my requirement. So plz could u tell me how to solve this problem. I tried making UpdateGrid() function as public and calling this function from add or edit on close event. but it haven't update my grid. Thank you for your support. Inpreet Singh

    H 1 Reply Last reply
    0
    • I Inpreet Singh

      Hello, I am using Datagrid to show records and there are two buttons for Add new record and edit record. when add or edit button is clicked new form is opened where user enter data n after clicking ok on that form activation returns to datagrid form. Now the problem is, I want to execute UpdateGrid() method which shows updated data into grid. This can be called on Activated event of the form but if that form is MDI child Activated event does not work. so after editing or add new record I don't have any event to raise to update data into grid. If I don't make grid form as MDI child Activated event work properly but that doesn't fullfill my requirement. So plz could u tell me how to solve this problem. I tried making UpdateGrid() function as public and calling this function from add or edit on close event. but it haven't update my grid. Thank you for your support. Inpreet Singh

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Instead of handling events on the DataGrid, it's better to handle events on the DataSet if you're using one, or rather the DataTable(s) contained in the DataSet. The DataTable has many events (like RowChanged and RowDeleted) you can handle. These are fired before or after (depending on which events you use) the underlying data source is updated. The DataGrid itself has no effective means to know when the data source was changed. If you're not using a DataSet, you can either use appropriate events for the IList or IListSource implementation (like an ArrayList) if any are exposed, or add events by extending the class or creating your own wrapper class.

      Microsoft MVP, Visual C# My Articles

      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