473,320 Members | 1,814 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,320 software developers and data experts.

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 2260
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.MakeChanges();
}

}
Hope this help,

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

"cm@gowcity" <cm@gowcity.fsnet.co.uk> wrote in message
news:5f*************************@posting.google.co m...
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.fsnet.co.uk (cm@gowcity) wrote in message news:<5f*************************@posting.google.c om>...
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
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...
4
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...
4
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...
3
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...
0
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...
5
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
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...
8
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
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...
2
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.