Click here to Skip to main content
15,893,190 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can get IP Address from local machine? Pin
Uwe Keim30-May-04 22:28
sitebuilderUwe Keim30-May-04 22:28 
QuestionWrap Datagrid Column in WinApp Project? Pin
Tuwing.Sabado30-May-04 17:10
Tuwing.Sabado30-May-04 17:10 
AnswerRe: Wrap Datagrid Column in WinApp Project? Pin
Mazdak30-May-04 20:17
Mazdak30-May-04 20:17 
GeneralRe: Wrap Datagrid Column in WinApp Project? Pin
Tuwing.Sabado30-May-04 20:20
Tuwing.Sabado30-May-04 20:20 
QuestionHow can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Tuwing.Sabado30-May-04 17:02
Tuwing.Sabado30-May-04 17:02 
AnswerRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Aryadip30-May-04 18:21
Aryadip30-May-04 18:21 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Tuwing.Sabado30-May-04 20:45
Tuwing.Sabado30-May-04 20:45 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Aryadip30-May-04 21:48
Aryadip30-May-04 21:48 
hi,
look what you can do in this senario is :

On the button click event (before showing the 2nd form)...
Store the value of the textbox in a public variable...

Pass the object the the parent class to the 2nd form thru constructor

In the 2nd form use the parent form's object to access the public variable of the parent.

Now to access the textbox of the 2nd form from the parent:

declare a public variable in the 2nd form and set itz value with the text box value...

In the parent form you already have the object of the send... bcoz you r showing the 2nd from the parent...
So use the object to access the public variable of the 2nd form...

for example:

// the parent form
class parent : Form
{
// public variable in parent form to hold the textbox value
public string textVal = "";
...
...
// button click event delegate in parent form
private void button_click(...)
{
// store the textbox value in the public variable
textVal = textBox1.Text;

// instantiate child form with parent object in the constructor
childForm form2 = new childForm(this);
// showing the child form as modal dialog
form2.ShowDialog();
// after dialog is closed accessing the textbox value of the child form
MessageBox.Show(form2.textValChild);
// destroying the child form
form2.Close();
}
}

// the child form class
class childForm : Form
{
// public variable in the child form to store the textbox value of the child
public string textValChild = "";
private Form objparent = null;

// child form constructor with the parent form object
public childForm(Form parent)
{
this.objparent = parent;
}
...
...
// in the button click event delegate
private void Textbox2_Click(...)
{
// displaying the parent form textbox value
MessageBox.Show(this.objparent.textVal);

// storing the child form textbox value
this.textValChild = TextBox2.Text;
//hiding the child form... don't close otherwise itz object will be destroyed
this.Hide();
}
}

Hope this helps you...

regards,
Aryadip.

Cheers !! and have a Funky day !!

GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Tuwing.Sabado30-May-04 22:50
Tuwing.Sabado30-May-04 22:50 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Aryadip31-May-04 2:44
Aryadip31-May-04 2:44 
AnswerRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
partyganger31-May-04 5:26
partyganger31-May-04 5:26 
Generalweb chat! Pin
Silly Boy30-May-04 16:48
Silly Boy30-May-04 16:48 
GeneralRe: web chat! Pin
Wackatronic1-Jun-04 10:05
Wackatronic1-Jun-04 10:05 
GeneralAccessing controls later in code.... Pin
torn8830-May-04 10:45
torn8830-May-04 10:45 
GeneralRe: Accessing controls later in code.... Pin
Peff30-May-04 14:45
Peff30-May-04 14:45 
GeneralMaking a tray icon Pin
Otis_6930-May-04 10:42
Otis_6930-May-04 10:42 
GeneralRe: Making a tray icon Pin
Nathan Blomquist30-May-04 17:17
Nathan Blomquist30-May-04 17:17 
GeneralRe: Making a tray icon Pin
Otis_6930-May-04 17:39
Otis_6930-May-04 17:39 
GeneralRe: Making a tray icon Pin
Nathan Blomquist30-May-04 18:37
Nathan Blomquist30-May-04 18:37 
Generalhide console window Pin
Otis_6930-May-04 10:40
Otis_6930-May-04 10:40 
GeneralRe: hide console window Pin
Stefan Troschuetz30-May-04 22:18
Stefan Troschuetz30-May-04 22:18 
GeneralRe: hide console window Pin
Otis_6931-May-04 9:33
Otis_6931-May-04 9:33 
GeneralRe: hide console window Pin
Stefan Troschuetz31-May-04 10:33
Stefan Troschuetz31-May-04 10:33 
GeneralRe: hide console window Pin
Otis_6931-May-04 11:43
Otis_6931-May-04 11:43 
GeneralForce termination of a thread Pin
Otis_6930-May-04 10:17
Otis_6930-May-04 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.