1 Replies - 312 Views - Last Post: 21 November 2009 - 06:12 PM Rate Topic: -----

#1 chromatinpt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-November 09

controls in 3rd form

Posted 21 November 2009 - 03:50 PM

Hello,

I have some app like this:

Form1 (Parent) -> open in load event a Form2 (child) which have a button that open a 3rd one child form (then close Form2).

My question is how I can access a control property (like labeltext (in statusbar) in Form1)?

Form1 Parent
 private void Form1_Load(object sender, EventArgs e)
		{
		  Form2 chForm2 = new Form2();
		  chForm2.MdiParent = this;
		  chForm2.Show();						  
		 }


Form2 Child
Button click event
			Form3 chForm3 = new Form3();
			chForm3.MdiParent = Form1.ActiveForm;
			chForm3.Show();



Now in Form1 I have a labeltext in statusbar that I want to control from Form3.

Thanks a lot!

Is This A Good Question/Topic? 0
  • +

Replies To: controls in 3rd form

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: controls in 3rd form

Posted 21 November 2009 - 06:12 PM

The easiest way would be to create a public static method on Form1 that would take as a parameter what you want to do with the status bar. If you wanted to set the Text property of part of it pass in a string.

On Form1
public static void SetText(string text)
{
	// set the Text property to the text vale
}



On Form3
Form1.SetText("text to set");


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1