DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Access to a master form, from a component class (http://www.daniweb.com/forums/thread157648.html)

msd1357 Nov 16th, 2008 2:10 am
Access to a master form, from a component class
 
Hello,
I create a component class in Visual Studio 2008 in a windows form application. This component has a property named "MasterFormName", which should contain name of the form that component will place on it. I want that the MasterFormName property be a read only property and when I dragging it to my form at design time, it automatically take the master form name that contains the component, without directly writing by user. How could I achieve this ability? I think that I should found a way to access any master form from the component class, But how do this?
Regards…

MRafeie Nov 16th, 2008 7:20 am
Re: Access to a master form, from a component class
 
Hi
You can use the ParentForm property of your component easily. For example:
this.MasterFormName = this.ParentForm.Name;

MRafeie Nov 17th, 2008 5:07 am
Re: Access to a master form, from a component class
 
Hint: If you drag your component on to another control (any thing else a Form) you will recieve a null exception error.


All times are GMT -4. The time now is 7:39 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC