Solved

c# mdiparent accessing the controls from child form

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

8 Experts available now in Live!

Get 1:1 Help Now