Getting Data From Calling Form
-
I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University
-
I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University
Hi Guds, 1) You can pass the instance of the main form to the child form and can access the values from that object. 2)You can use delegate to access the values of the main form in the child form. Thanks and Regards SGS
-
I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University
It's fairly simple, just pass the reference to the main form to the modeless form. Something like
class MainForm : Form
{
public void ShowForm()
{
ChildForm f = new ChildForm(this);
f.Show();
}
}class ChildForm : Form
{
MainForm mainForm;
public ChildForm(MainForm f)
{
mainForm = f;
}void SomeFunc() { int data = mainForm.data; }
}Regards Senthil _____________________________ My Blog | My Articles | WinMacro