Solved

c# mdiparent accessing the controls from child form

Posted on 2013-01-22
5
1,866 Views
Last Modified: 2013-01-22
Hi

I have an application in which consists of an mdiparent which will house the links to various modules in the application.  The first thing a user sees is a login form, upon successful login, they are to be presented with a row of buttons on the mdiform for the modules that their account gives them access to.

how can I add the buttons to the mdiparent, or make them 'visible' in this way?

CHeers

CD
0
Comment
Question by:cycledude
  • 2
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38805909
Either add a ToolStrip control to your MdiParent, or add a Panel to the MdiParent and set its Dock() property to Top (then add Buttons to the Panel).
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38805920
you can try this:


1 make them in a child form, dock them on the bottom,
use On_load, child.show. child.parent = me

or

2 get something like infragistics, and use the status bar to add buttons to it


or

3. drag a panel or groupbox to the paent, and add buttons inside it



hope that helps
0
 

Author Comment

by:cycledude
ID: 38805965
Hi

I have got a panel with buttons inside it on the parent mdi form, but how do I access them from the child form...

when the user clicks login on the child form I am accessing the database to see if the credentials are correct.  If they are correct, I need to check the users access rights within the system and display the corresponding controls...

I thought I may have been able to do something like:

if (useraccess == 1)
{
 mdiparent.btnTask1.show;
 mdiparent.btnTask2.show;


}

do I need to make the buttons 'public'?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 38806024
Ah...gotcha.

Yes.  First you need to change the Modifiers() property of the those buttons to Public.

Next you have to CAST the MdiParent() property to the correct type.  For example, if the MdiParent was of type "frmMdiParent", then you'd do:

    // ...(from the MdiChild)...
    frmMdiParent main = (frmMdiParent)this.MdiParent;
    main.btnTask1.Visible = true;
    main.btnTask2.Visible = true;
0
 

Author Closing Comment

by:cycledude
ID: 38806057
perfecto, thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now