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

C# - Accessing controls of another form

2
In my current project I have a main MDI interface with a child form(Form 1) to select a datasource(Can be an access file).

Once the database file is specified the application tries to access it. If an authentication is required the exception is processed and a Login form(Form 2) is instantiated by Form 1.

Based on whether the authentication in Form 2 is valid, a listbox in Form 1 needs to be populated with the tables in the Access database. This leads to a scenario where the Form 2(originally instantiated by Form 1 but a child of the MDI Form) should be able to access the list box in Form 1, populate it and close.

How will Form 1 be able to access the list box control in Form 2? Is there any other way to implement a similar functionality?
Oct 6 '07 #1
2 1573
Shashi Sadasivan
1,435 Expert 1GB
Well...make the listbox publically available and pass form1 as a parameter to form2. Soonce the login is checks and it works populate form1.dropdown from form2.

Another way to do this.-->
open form1 -> choose a datasource(file) -> if authentication req open form2 as a modalDialog -> send the filename as param to form2 -> authenticate the file -> store the username and password in form2 as public variables and an identifier if the login succeeded -> in form1 after the showDialog method check is login succeeded-> if it did retrieve the username and pwd from form1, and populate the drop down

cheers
Oct 6 '07 #2
aiyaz
2
Thanks a lot shashi, I used the second approach you gave..............works good and is the less messier one :)

Well...make the listbox publically available and pass form1 as a parameter to form2. Soonce the login is checks and it works populate form1.dropdown from form2.

Another way to do this.-->
open form1 -> choose a datasource(file) -> if authentication req open form2 as a modalDialog -> send the filename as param to form2 -> authenticate the file -> store the username and password in form2 as public variables and an identifier if the login succeeded -> in form1 after the showDialog method check is login succeeded-> if it did retrieve the username and pwd from form1, and populate the drop down

cheers
Oct 7 '07 #3

Sign in to post your reply or Sign up for a free account.

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: 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...
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...
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.