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…

Hi
You can use the ParentForm property of your component easily. For example:
this.MasterFormName = this.ParentForm.Name;

Hint: If you drag your component on to another control (any thing else a Form) you will recieve a null exception error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.