473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to change control properties in Form1 from Form2

Hello,

I have Form1 - the main form with some controls including a button.

I have Form2 - the properties form with a combobox and button. The user can
select the colors of a button in the combobox in Form2 and press "OK". What
code should I add to "OK" so that the user can change the colors of a button
in Form1?

Mateusz
Dec 13 '05 #1
3 2470
Public variables must be created in the receiving form, such as:
In Form1:
public Color col;

then this variable can be called and written to.

The form(s) also need a definitive reference to one another. Not to
just the class such as Form1.xxx, but to the specific instance of the
form in question, such as:

In Form1:
Form2 myKid = new Form2;
myKid.myDad = this;
myKid.Show();
In Form2:
public Form1 myDad;

then you can write code in Form2 such as:
myDad.col = Color.FromARGB(206, 206, 244);
This code is not tested and is informational, but should be enough to
get you going.

Bob
Mateusz Rajca wrote:
Hello,

I have Form1 - the main form with some controls including a button.

I have Form2 - the properties form with a combobox and button. The user can
select the colors of a button in the combobox in Form2 and press "OK". What
code should I add to "OK" so that the user can change the colors of a button
in Form1?

Mateusz


Dec 13 '05 #2
Thanks! Ill try it

"RvGrah" wrote:
Public variables must be created in the receiving form, such as:
In Form1:
public Color col;

then this variable can be called and written to.

The form(s) also need a definitive reference to one another. Not to
just the class such as Form1.xxx, but to the specific instance of the
form in question, such as:

In Form1:
Form2 myKid = new Form2;
myKid.myDad = this;
myKid.Show();
In Form2:
public Form1 myDad;

then you can write code in Form2 such as:
myDad.col = Color.FromARGB(206, 206, 244);
This code is not tested and is informational, but should be enough to
get you going.

Bob
Mateusz Rajca wrote:
Hello,

I have Form1 - the main form with some controls including a button.

I have Form2 - the properties form with a combobox and button. The user can
select the colors of a button in the combobox in Form2 and press "OK". What
code should I add to "OK" so that the user can change the colors of a button
in Form1?

Mateusz


Dec 13 '05 #3
What code should I add so I can change the default homepage for my web
browser in a preferences dialog?

"RvGrah" wrote:
Public variables must be created in the receiving form, such as:
In Form1:
public Color col;

then this variable can be called and written to.

The form(s) also need a definitive reference to one another. Not to
just the class such as Form1.xxx, but to the specific instance of the
form in question, such as:

In Form1:
Form2 myKid = new Form2;
myKid.myDad = this;
myKid.Show();
In Form2:
public Form1 myDad;

then you can write code in Form2 such as:
myDad.col = Color.FromARGB(206, 206, 244);
This code is not tested and is informational, but should be enough to
get you going.

Bob
Mateusz Rajca wrote:
Hello,

I have Form1 - the main form with some controls including a button.

I have Form2 - the properties form with a combobox and button. The user can
select the colors of a button in the combobox in Form2 and press "OK". What
code should I add to "OK" so that the user can change the colors of a button
in Form1?

Mateusz


Dec 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ptass | last post by:
I have a main form (Form1) which opens a second form (Form2) when a button is clicked. Form2 has .FormBorderStyle set to FixedSingle. Form2 contains two buttons, one which unpins it from Form1...
1
by: Doug | last post by:
Hello, Can someone help me quickly w/ properties. I have 2 forms (say Form1 and Form2). When a user enters a value on Form1 I want to make it available to Form2. I declared a public property...
0
by: Kitchen Bin | last post by:
HELP PLEASE!! The C# Visual Studio IDE is failing to load an inherited form into the IDE from a base form when I add items to an array property of a user control on the base form. That sounds...
4
by: jcrouse | last post by:
I have an app with form1 and form2. Form1 has a label control. Form2 has a checkbox and OK button. By default the label on form1 is hidden. When I lauch my app form1 is the default. I right click on...
4
by: Carlos | last post by:
In VB6 I was able to accessa control like a progressbar form a different form, for example frm1.progressbar1.value =XXX but now how can I do that in VB.NET Thanks
2
by: Tom | last post by:
Let's say I have written a VB.NET user control, with the following components: MyControl.sln MyUserControl.vb (user control) Form1 (Windows Form) Form2 (Windows Form) Now, lets say that...
6
by: AMP | last post by:
Hello, I have an mdi program with a child form ("A") and another child ("B"). I want to change the text of a label on A by changing an item from a combobox on B. I can code the...
6
by: Mat | last post by:
Dear all, What I want to do is be able to use a string to refer to a control on a subform. IE: Forms!("Form1!form2!controlA").name or
6
by: Ali | last post by:
Hello How can I change a property of a control from From2 but the control is in Form1. I wrote these code in Form2 but didnt work. Dim f as new form1 f.Textbox1.Text = "hello world"
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.