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
Printable View
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
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.,
BTW, you are never disposing of your child form, that is why I wrapped it in a using statement.Code:using ( Form1 child = new Form1( ) )
{
child.ShowDialog( );
this.Invalidate( );
}
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?
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.
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.
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.
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.
No, the data gets written properly, just the previous form does not refresh.
Would adding
to the focus activated event fix this problem?Code:this.Refresh();
or do i add it to the focus enter event.
Just try it adding and see if it worked or not.
by a databinding
disregard case (the select mode is for the whole row in the Datagirdviewer):
in form1 i edit some of the rows, and then close the form with:Code:string s = DGVS.SelectedRows[0].Cells["ID"].Value.ToString();
form1 form1instance = new form1();
form1instance.s = s;
form1instance.showdialog();
the first form will not update automaticallyCode:this.close();