Solved

c# mdiparent accessing the controls from child form

Posted on 2013-01-22
5
1,826 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

13 Experts available now in Live!

Get 1:1 Help Now