473,395 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# refreshing Datagridview from a different form

Hello; i am having some problems trying to get a form that has a
datagridview to refresh after a new record is created.

I have a MDI container and menu form and add new record form; the menu
form display the data using a data grid view and the add record form
creates an object and passes that data to a class method which creates
the record using sqlcommand.

The add new record form is loaded after the user clicks on the add
button on the menu form, from there the user enters all the data
required, but once the user is done and clicks on Ok, the new record
is created, but the datagrid has to be refreshed and thats where i am
having problems.

I would think that the refresh() method would be called right after
the connection close() method or before, but since the datagrid is
located on a different form, the add record form cant see the
datagridview in order to call the refresh() method...

Any thoughts on how to refresh a datagridview located on form1 from a
different form...?

thanks..?

Apr 22 '07 #1
1 4911
On Apr 21, 10:34 pm, rome...@gmail.com wrote:
Hello; i am having some problems trying to get a form that has a
datagridview to refresh after a new record is created.

I have a MDI container and menu form and add new record form; the menu
form display the data using a data grid view and the add record form
creates an object and passes that data to a class method which creates
the record using sqlcommand.

The add new record form is loaded after the user clicks on the add
button on the menu form, from there the user enters all the data
required, but once the user is done and clicks on Ok, the new record
is created, but the datagrid has to be refreshed and thats where i am
having problems.

I would think that the refresh() method would be called right after
the connection close() method or before, but since the datagrid is
located on a different form, the add record form cant see the
datagridview in order to call the refresh() method...

Any thoughts on how to refresh a datagridview located on form1 from a
different form...?

thanks..?
I ran into a similar situation. What I did had the parent from being
the one containing the DataGridView. Then a child form would open
where I would add/change one of the DataRows. When I went to commit
the change I wanted the parent form to have its DataGridView refreshed
to reflect the add/change in the child form. What I did was pass the
parent form's DataTable (that its DataGridView is based on) into of
the child form through an initialization parameter. This way it had a
reference point. Then when the child form did its thing I would use a
TableAdapter in the child form to invoke its Fill method to refresh
the DataTable that was passed in from the parent form. Not sure if
this is necessarily the preferred way of doing this, but it worked for
me!

Apr 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RSH | last post by:
I have a situation where I have a Master form that contains a DataGridView. Each row has a details... button that spawns a new winform which shows many more fields than the DataGridView. The user...
0
by: Bob | last post by:
I have relational integrity set up in my sql server 2005 database that prevents cascading deletes in some cases. I'm using a bound datagrid view and a tablenavigator. When I click the delete...
1
by: Bob | last post by:
During a form's development I noticed that when I changed bound dataset defintions with the dataset designer (for instance adding a column to one), when I come back and look at the form the...
0
by: Robert Bravery | last post by:
Hi all, How can I refresh or repaint the datagridview after scrolling up or down. Cuurently if I resize the form slightly, the datagridview is then repainted correctly Thanks RObert
3
by: steve | last post by:
Hi All How can I get the datagridview to redraw after changing the rowtemplate.height at runtime ( it is databound to a datatable) I have tried datagridview1.refresh etc to no avail (The row...
0
by: lv2compute | last post by:
I am having a problem with my datagridview. I have a small table that has two columns. The first column is bound to my dataset. The second column is a combobox. I add items to the combobox based on...
2
by: snowdog17 | last post by:
Hello, I am a student and I need help with my VB task. I am currently using VB 2005 Express and I am fairly new to it, although I have programed in Delphi before....
1
by: Arved Sandstrom | last post by:
This seems to be something so simple that none of the hundred-odd tutorials and forum threads that I have looked at (:-)) apparently thinks it's a problem. In a nutshell, I have two...
1
by: Andrus | last post by:
I have Winforms DataGridView whose DataSource Rids is Marc sample TableListCollection<TRowderived from BindingList. It is used to edit invoice rows. If user presses Revert button, my application...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.