473,664 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2489
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
1315
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 by setting ..ShowInTaskBar to true, and setting .Owner to false. The other buttons click event reverses, this by setting .Owner to the form1 instance, and .ShowIntTaskBar to false. This all works fine, with Form2appearing in the taskbar and...
1
1281
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 on Form2 and on Form1 set the property (declared on Form2) to the value then tried to use it on Form2. This isn't working...see code below. Form2....
0
1476
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 confusing but let me explain: I have a UserControl, let's call it "ButtonArrayControl", and also a separate class for holding various properties: public class MyButtonProperties
4
1381
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 the form and select "Add Labels" from the context menu. This takes me to form2 where I can then select the checkbox if I want to turn on the label back on form1. This works great. I then select the "OK" button on form2 and executed the following code...
4
13947
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
4710
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 within the MyUserControl I have a public function that can be called, and that function causes the Form1 form to load in
6
6872
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 comboBox1_SelectedIndexChanged that is on B but I dont know how to send that info to the label on A.I cant seem to access A from B. Help Thanks Mike
6
2742
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
1609
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
8437
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.