3 Replies - 1324 Views - Last Post: 31 January 2009 - 10:03 AM Rate Topic: -----

#1 kierien  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-January 09

Editing Objects On Other Forms, and diffrent methods on calling upon F

Posted 30 January 2009 - 09:36 PM

Hey,

I've been having a problem with forms lately.

First of is there any other way of calling upon a form, apart from

Form1 Lawl = new Form1();
Lawl.Show()


Cause that launches a new form, which i dont want, is there a work around on this?

The other thing would be editing objects on other forms.

In vb.net you could easily just

Form1.TextBox1.Text = "Lawl"


How do you do this in C#?

Any help would be greatly appreciated.

~kierien

Is This A Good Question/Topic? 0
  • +

Replies To: Editing Objects On Other Forms, and diffrent methods on calling upon F

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Editing Objects On Other Forms, and diffrent methods on calling upon F

Posted 30 January 2009 - 09:57 PM

The way you call a form is not the only way to actually call it. You can show a modal form (dialog):

Form1.ShowDialog();



In C#, to access control properties of the controls that are on another form, you have to change the scope of the control. By default it is Private. You will have to change it to Protected Internal or anything else suitable for your application. But this won't be enough. You will either have to create a property that will return a specific value to a control property (this is the recommended way) or make the form that contains the control you want to modify the owner of the form that will modify the control.

This post has been edited by Core: 30 January 2009 - 09:59 PM

Was This Post Helpful? 1
  • +
  • -

#3 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Editing Objects On Other Forms, and diffrent methods on calling upon F

Posted 30 January 2009 - 10:01 PM

Welcome!

Quote

Cause that launches a new form, which i dont want, is there a work around on this?

What are you trying to do?

With regard to passing data between forms have a look at this CodeProject article: Passing Values between Forms
Was This Post Helpful? 0
  • +
  • -

#4 kierien  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-January 09

Re: Editing Objects On Other Forms, and diffrent methods on calling upon F

Posted 31 January 2009 - 10:03 AM

Thanks guys, problem solved.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1