473,382 Members | 1,322 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,382 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 2469
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.