473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing controls on another form

cm
HI, here's my problem;

My application loads up 3 forms at startup.
Deppending on what button is press on form1 i want to show or hide
controls on form2.
I cant seem to get access to the controls on from2 to hide them unless
i create another instance from within form1 which i dont want to do. i
just want to use the one creted when the program starts up.

Any ideas?
Nov 15 '05 #1
2 2273
Hi,

Basically you need to keep a reference to the form2 in form1 , in such a
way that when you need to make changes on form2 you have it accesible from
form1.
something like this:

class Form1 {
Form2 form2;

public Form1()
{
//create form2;
form2 = new Form2();
//as you show both forms from the very beginning , let's show it
form2.Show();
}
//Now I can do this:
protected button_OnClick( object s, EventArgs e )
{
form2.MakeChang es();
}

}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"cm@gowcity " <cm@gowcity.fsn et.co.uk> wrote in message
news:5f******** *************** **@posting.goog le.com...
HI, here's my problem;

My application loads up 3 forms at startup.
Deppending on what button is press on form1 i want to show or hide
controls on form2.
I cant seem to get access to the controls on from2 to hide them unless
i create another instance from within form1 which i dont want to do. i
just want to use the one creted when the program starts up.

Any ideas?

Nov 15 '05 #2
cm@gowcity.fsne t.co.uk (cm@gowcity) wrote in message news:<5f******* *************** ***@posting.goo gle.com>...
HI, here's my problem;

My application loads up 3 forms at startup.
Deppending on what button is press on form1 i want to show or hide
controls on form2.
I cant seem to get access to the controls on from2 to hide them unless
i create another instance from within form1 which i dont want to do. i
just want to use the one creted when the program starts up.

Any ideas?


You could also use delegates.
check out
http://www.codeproject.com/csharp/#Delegates+and+Events

for examples using delegates.
Nov 15 '05 #3

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

Similar topics

3
15099
by: Tom Meuzelaar | last post by:
Hello: I'm using VB6 in VS enterprise. I'd like to place an HTML form inside a VB container, have a user fill out the form information, click a submit button, and then have the program capture the field values and write them to an ASCII file on the hard drive. Can anyone confirm that this is even possible? I have dredged up one article "Accessing the Internet Explorer Document Object Model from Visual Basic 5.0" (Asmi, 1998) that covers...
4
12097
by: Jim Heavey | last post by:
Hello, I have created a form which I intend to use a a dialog box. It has a few controls on that form and I changed the properties of those controls to "public" with the idea that I could access those controls from the "calling form", but I am unable to access/see those controls. Why? Here are portions of my code Here I am substantiating the new form and trying to set values for the controls on that form...
4
4339
by: Andrew Diabo | last post by:
I have 2 forms (Form1 and Form2) in my C# project. I created the second form from the main form like so: Fom2 aForm = new Form2(); aForm.ShowDialog(); How do I access the properties of a control (label1) in Form1 from Form2? Thanks Andrew
3
1336
by: Tim Fitzgerald | last post by:
Hello all, I have no problem accessing another form in my app.. however, when I try to access a ListView on a different form, I come up empty... Basically, Dim pForm As New frmMain Dim iCount As Integer iCount = pForm.lvJobList.Items.Count
0
1419
by: Geraldine Hobley | last post by:
Hello I have a problem whereby I have a treeview control on one form called projecttree and I wish to clea the nodes from this control in another form The form that contains the treeview is called projecttree and the form that I wish to clear the node from the tree, (because I'm connecting to a different database) is called frmConnections The forms are on the screen at the same time, and they are of type crownwood docking control ...
5
1942
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
4
3622
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if possible.. for example..i hav a menu in the parent form named "Administrator" whic has an item "mnuLogIn"..now when i click on login..another child form named "frmLogIn" is displayed..what i want to happen is this: when login form(frmLogIn) is...
8
2176
by: colmkav | last post by:
Hi, could someone tell me how I can check whether a database is open by name eg something like db("mydbname")
3
2209
by: M K | last post by:
I have 2 classes. One where the form resides and I created another one for all the database stuff. after i get data from the db i want to be able to update the form. I have the namespace of where the form code is but how do i get to the controls themselves. newbie in the class world.. still trying to figure it all out :) Thanks for any help...
2
3042
by: San24 | last post by:
Guys, Let me explain the application I have - Form > Main Tab Control > Main Tab Page > User Control > Sub Tab Control > Sub Tab Page > User Control > Contols/Text Box. Form - The main form Main Tab Control - This contains Main Tab Pages.
0
8384
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
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8499
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
8601
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
6162
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
5630
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
4150
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...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
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.