7 Replies - 1672 Views - Last Post: 01 September 2011 - 11:10 AM Rate Topic: -----

#1 Da-Coder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 12-August 11

Refreshing a data grid view

Posted 01 September 2011 - 09:11 AM

Hello,

I am looking to refresh a data grid view (dgv) that's tied to a data source. Currently the dgv updates a record but doesn't refresh the record. So the user has to back out of the form and then reenter it to see the updated record. I need to make the dgv refresh as soon as the user updates the record. Currently I have the following code:

                    dataGridView1.Refresh();
                    dataGridView1.Parent.Refresh();



This doesn't do anything. Any suggestions on how to go about this?

Is This A Good Question/Topic? 0
  • +

Replies To: Refreshing a data grid view

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8377
  • View blog
  • Posts: 31,135
  • Joined: 12-June 08

Re: Refreshing a data grid view

Posted 01 September 2011 - 09:17 AM

Are you asking to refresh the data or the grid UI?

If it's the data then right after a successful update call your 'data load' method though you have to wonder if the data was just updated in the grid why make another round trip to bring what you already have there back.

If it's the UI - what are you looking for the UI to do?
Was This Post Helpful? 0
  • +
  • -

#3 Da-Coder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 12-August 11

Re: Refreshing a data grid view

Posted 01 September 2011 - 09:22 AM

Currently the dgv doesn't show the updated record right away. The user has to re-enter the form to see the updated record or a new record for that matter. I guess I need to have the dgv refresh so it displays the updated fields as soon as the user updates them. Right now the user has to leave the form, then re-enter to see their updated record or new record.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8377
  • View blog
  • Posts: 31,135
  • Joined: 12-June 08

Re: Refreshing a data grid view

Posted 01 September 2011 - 09:33 AM

Are they entering this data into the grid directly or is this through some sort of popup form?
Was This Post Helpful? 0
  • +
  • -

#5 Da-Coder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 12-August 11

Re: Refreshing a data grid view

Posted 01 September 2011 - 10:23 AM

They are entering the data on a textbox, and date time picker which then gets added to the database. So not directly on the data grid.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8377
  • View blog
  • Posts: 31,135
  • Joined: 12-June 08

Re: Refreshing a data grid view

Posted 01 September 2011 - 10:41 AM

Well then, when the entry form closes have call the method to load the data to the grid. It should be just that straight forward.

Well that or when the entry form is closed (but not disposed!) have it pull the data entered and you add to the grid. Though I wouldn't do that unless you are desperate about not making another trip to the database.
Was This Post Helpful? 0
  • +
  • -

#7 Da-Coder  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 12-August 11

Re: Refreshing a data grid view

Posted 01 September 2011 - 10:54 AM

Ok so here's the layout of my form. I have a panel that contains labels docked on top (north). The dgv is docked as fill. I have tab panel that is docked on the bottom (south). The bottom panel contains the text box along with the date time picker that I talked about earlier. When the user makes changes to the text box or date time picker, it should automatically refresh the dgv. There's no pop up control for the users. It's all in one form that contains three separate panels.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8377
  • View blog
  • Posts: 31,135
  • Joined: 12-June 08

Re: Refreshing a data grid view

Posted 01 September 2011 - 11:10 AM

Well even easier. When the update call is done do a load call.

I am not getting why "call method_B after method_A" is difficult. ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1