|
-
September 3rd, 2009, 01:33 PM
#1
Refreshing a form
right now i have a form that creates an instance of anouther form
(
form1 form1instance = new form1();
form1instance.showdialog()
)
the user makes changes in form1instance, and then exits the form.
how can i refresh the parent form?
using .net 3.5
-
September 3rd, 2009, 01:39 PM
#2
Re: Refreshing a form
Why do you need to repaint the parent form? What changes that necessitates a repaint?
To answer your question directly, just call Invalidate() on your parent form, i.e.,
Code:
using ( Form1 child = new Form1( ) )
{
child.ShowDialog( );
this.Invalidate( );
}
BTW, you are never disposing of your child form, that is why I wrapped it in a using statement.
-
September 3rd, 2009, 01:47 PM
#3
Re: Refreshing a form
to explain, there is a table in the parent form, and one of the options that i am giving the user is the ability to add, edit and delete rows.
after the changes are made, and the form is close, no changes will be made to the parent form (i.e. it will still show the rows as the were, not as they are post edit)
what does this.invalidate do?
-
September 3rd, 2009, 02:04 PM
#4
Re: Refreshing a form
Well, the grid should update when you add the new rows in. I have a feeling that you are adding the rows to the control in your child form and expecting them to appear in your main form. That will not work, they are two different controls. You should probably make a new form class for adding the data and then make that data a property which can be read by the mainform when the child closes.
Invalidate() forces a repaint of a control. That is not what you need here.
-
September 3rd, 2009, 02:11 PM
#5
Re: Refreshing a form
no, i am adding the data to the underlying source of the table.
in this case, the table is drawn from a database, and the user can add edit and delete records.
i want those changes to appear in the parent.
-
September 3rd, 2009, 02:44 PM
#6
Re: Refreshing a form
Ahhh, ok. I have never actually used bound data sources like that, so perhaps you should post your code and let one of the other members chime in.
-
September 6th, 2009, 04:21 PM
#7
Re: Refreshing a form
 Originally Posted by soandos
no, i am adding the data to the underlying source of the table.
in this case, the table is drawn from a database, and the user can add edit and delete records.
i want those changes to appear in the parent.
Ok
at first as I see other threads with similar problems from you:
1) Is your adding data to the table really working ?
That means when you add some data can you see them occuring in the databasetable or re they not to be seen there
2) Have you debugged if the data are really added to the table ?
because if your datagrid in the maiform is bound to that table and your table is really updated so using the debugger you can see them existing in the databale and they are also stored in the database then you need to look how your datagrid is bound to the table, because it normally should update automatically otherwise simple try to refresh your Datagridview.
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
September 6th, 2009, 09:02 PM
#8
Re: Refreshing a form
No, the data gets written properly, just the previous form does not refresh.
Last edited by soandos; September 6th, 2009 at 09:08 PM.
Reason: forgot witch post i was on
-
September 6th, 2009, 09:12 PM
#9
Re: Refreshing a form
Would adding
to the focus activated event fix this problem?
or do i add it to the focus enter event.
Last edited by soandos; September 6th, 2009 at 09:17 PM.
Reason: addition
-
September 7th, 2009, 12:48 AM
#10
Re: Refreshing a form
Just try it adding and see if it worked or not.
-
September 7th, 2009, 02:11 AM
#11
Re: Refreshing a form
 Originally Posted by soandos
No, the data gets written properly, just the previous form does not refresh.
OK in which way is it connected to the DataSet or DataTable , or if you cannot find out zip a testdatabase and the project and show it. (For zipping the project delete data in BIN and OBJECT files then zip the project
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
September 7th, 2009, 11:42 AM
#12
-
September 7th, 2009, 02:39 PM
#13
Re: Refreshing a form
 Originally Posted by soandos
by a databinding
Yea sure, but IMHO you need to post code as this sounds strange.Normally that would work
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
September 7th, 2009, 09:55 PM
#14
Re: Refreshing a form
disregard case (the select mode is for the whole row in the Datagirdviewer):
Code:
string s = DGVS.SelectedRows[0].Cells["ID"].Value.ToString();
form1 form1instance = new form1();
form1instance.s = s;
form1instance.showdialog();
in form1 i edit some of the rows, and then close the form with:
the first form will not update automatically
-
September 8th, 2009, 05:03 AM
#15
Re: Refreshing a form
 Originally Posted by soandos
disregard case (the select mode is for the whole row in the Datagirdviewer):
Code:
string s = DGVS.SelectedRows[0].Cells["ID"].Value.ToString();
form1 form1instance = new form1();
form1instance.s = s;
form1instance.showdialog();
in form1 i edit some of the rows, and then close the form with:
the first form will not update automatically
Sorry this is nothing where I can think with.
as I still cannot see any code how th Datagridview is exacly filled nor where it is updated. You cannot solve your problem without debugging so how should I debug it by this lines of unworkable code
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|