Changing control properties on different form in C# 
Author Message
 Changing control properties on different form in C#

Hi

How can I change properties of controls on a different form. For example, to
access statusBar1 on frmStatus from another form I thought I would code as
follows:

Form myForm1 = new FormTemplate();

myForm1.checkbox.checked = true;

myForm1.Show();

How come I can't see this control on the list?

And second lets say I'm creating IM and on request I need to create new from
(where user types and recived messages from other users) How do I control
forms from another form (I need to know what is what in order to send a
message to a proper from)

Thaks



Mon, 20 Sep 2004 20:35:59 GMT  
 Changing control properties on different form in C#
Sebasian,

    I thought you wanted to access the status bar?  Why is it called a
checkbox then?

    It doesn't matter really.  All of your controls are declared as
protected, so when you access the form from outside of the form, they don't
appear as public members.  Switch the members access level to public and you
will be able to see them.  However, from a design standpoint, this isn't a
good idea.  You should have methods on your form that do this for you.

    As for controlling forms from another form, all you need to do is have a
reference to the form in the other form and you will be set.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Hi

> How can I change properties of controls on a different form. For example,
to
> access statusBar1 on frmStatus from another form I thought I would code as
> follows:

> Form myForm1 = new FormTemplate();

> myForm1.checkbox.checked = true;

> myForm1.Show();

> How come I can't see this control on the list?

> And second lets say I'm creating IM and on request I need to create new
from
> (where user types and recived messages from other users) How do I control
> forms from another form (I need to know what is what in order to send a
> message to a proper from)

> Thaks



Mon, 20 Sep 2004 21:40:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How can I change other form property ?

2. Updating the value of a control on a different form

3. dialog, form view, and control layout on different system

4. dialog, form view, and control layout on different systems

5. dialog, form view, and control layout on different systems

6. Changing Menu Background Color in C# Windows Forms

7. User Controls: Accessing Properties (a slightly different point of view)

8. Property Page-Like Behavior Using Tab Control in Form Views

9. Changing cursor for different controls

10. Programmatically Creating Excel Form and Controls from C#

11. Unable to add custom C# control to a form - Exception from HRESULT: 0x80131019

12. C# ASP.NET Forms - Client Side Validation using Custom Validator Control

 

 
Powered by phpBB® Forum Software