Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am writing a small scheduler application. In this i need to move 3 fields of data from child back to parent form. code is as follows.
C#
private void calendar1_DoubleClick(object sender, EventArgs e)
        {
         AppointmentDialog _appDialog = new AppointmentDialog(MembersDT);
            
            if (_appDialog.ShowDialog() == DialogResult.OK)
            {
   DataRowView drv = (DataRowView)mycombo.SelectedItem;
                textBox1.Text = drv.Row.ItemArray[0].ToString();
                textBox2.Text = drv.Row.ItemArray[1].ToString();
                textBox3.Text = drv.Row.ItemArray[2].ToString();
            }
        }

now I have three fields in textbox1, textbox2, textbox3 . I need them to update in parent form. Kindly suggest.

chowdary.
Posted
Updated 26-Sep-12 2:15am
v2

 
Share this answer
 
Declare those 3 values as public members of the AppointmentDialog class.
When DialogResult.OK then copy from the AppointmentDialog class.
 
Share this answer
 
C#
public static string FirstValue ="";
public static string SecondValue ="";
public static string ThirdValue ="";

private void calendar1_DoubleClick(object sender, EventArgs e)
{
   AppointmentDialog _appDialog = new AppointmentDialog(MembersDT);

   if (_appDialog.ShowDialog() == DialogResult.OK)
   {
      DataRowView drv = (DataRowView)mycombo.SelectedItem;
      textBox1.Text = drv.Row.ItemArray[0].ToString();
      textBox2.Text = drv.Row.ItemArray[1].ToString();
      textBox3.Text = drv.Row.ItemArray[2].ToString();
      FirstValue    = drv.Row.ItemArray[0].ToString();
      SecondValue   = drv.Row.ItemArray[1].ToString();
      ThirdValue    = drv.Row.ItemArray[2].ToString();
   }
}

now you can get from parent form using child form name
Example:
C#
Child.FirstValue;
 
Share this answer
 
v3
Comments
Charles Shob 27-Sep-12 0:25am    
Sudheer, can you add code after the above??? Based on your words i cannot figure out. I am unable to access as you mentioned above lik

_appdialog.FirstValue
_appdialog.SecondValue
_appdialog.Thirdvalue



chowdary.
Charles Shob 27-Sep-12 7:20am    
Got clarified by myself. Thanks for the support.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900