数据Beteen表单C# [英] Data Beteen forms c#
本文介绍了数据Beteen表单C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我正在编写一个小的调度程序应用程序.在这种情况下,我需要将3个字段的数据从子级移回父级表单.代码如下.
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.
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();
}
}
现在我在textbox1,textbox2,textbox3中有三个字段.我需要它们以父级形式进行更新.请提出建议.
chowdary.
now I have three fields in textbox1, textbox2, textbox3 . I need them to update in parent form. Kindly suggest.
chowdary.
推荐答案
正确的方法: ^ ]
将这3个值声明为AppointmentDialog类的公共成员.
当DialogResult.OK时,则从AppointmentDialog类复制.
Declare those 3 values as public members of the AppointmentDialog class.
When DialogResult.OK then copy from the AppointmentDialog class.
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:
Child.FirstValue;
这篇关于数据Beteen表单C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文