hi, c# forms
-
I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always
-
I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always
Hi, in this scenario, define your entity object as a class, let Form1 have an static object of that class, in form two set the value for the static instance, then when u go back to form1 , do the data binding.. like this.. Form1 { public static CEntity objEntity; someclick() { Form2.showDialog() Datagrid.databind(objEntity) } } CEntity { Public string column1; Public string column2; } Form2 { someevent() { Form1.objEntity.column1 = textbox1.Text; Form1.objEntity.column2 = textbox2.Text; } } Cheers
-
I'm working with 2 forms Form1 and Form2. Logically Form1 is a parent form and Form2 is where a data input is requested from user. When Form2 opened upon Form1, user enters some data and Form2 exits. When Form2 exits, the datagrid in Form1 must be updated with new value. I'm trying to update datagrid with a code inside Form2.cs : //inside Form2.cs, a method of click of a button ...sql operations bla bla Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); But..... Datagrid doesn't always update, sometimes works. Any idea? A non-smart way I tried, to use focus event; but it doesn't focus anyway. Plz help may the force be with you, always
-
Form1 f = (Form1)this.owner; f.fillDataGrid(); // this method belongs to Form1 this.Close(); if these code wrote in the form2's closing or closed event?
I want to make some friends here