Windows Develop Bookmark and Share   
 index > Windows Forms Designer > UserControl share instance
 

UserControl share instance

Hi all

I have two usercontrols A and B witch should share the same instance of the third usercontrol C.

c= new Ccontrol();
a=
new
Acontrol();
b=
new Bcontrol();
a.C = c;
b.C= c;

ok this is working Iam getting the same instanse in both A and B. (simple)

But the problem is when displaying the C control. it is only showing on either A or B control depends on the oreder I put the C control in. The A and B controls are notvisable bothat same time. So when I switch betweeen A and B the C control only shows on the control witch got the C last (above the b control)


The C control is in a Panel, and I use a propertie to set it on like so.
public C c
{
get{return
c;}
set
{
this
.panel.Controls.Remove(c);
//clean up
c.Dispose();
c=
null
;
c=
value
;
panel.Controls.Add(c);
}
}

I've tried to suspend the layout on all and on nothing in differrent orders, resulting in same problem.

so the problem is as follow, the Control C only displays on either A or B, But is still there under the hood.

Best regards..


Thorri G  Tuesday, August 01, 2006 1:36 PM
Because an instance of a control can only have one UI instance. a.panel and b.panel can not be containers at the same time by control c.
JRQ  Tuesday, August 01, 2006 7:47 PM
is there any way to get a connection between a.panel b.panel as thatcontrol c seams to by the same control ? . with out using OnChange event. I'am trying to use Databind on the ccontrol to bind the all controlsto gather, but not working..
Thorri G  Wednesday, August 02, 2006 10:05 AM

You can use google to search for other answers

Custom Search

More Threads

• Some forms can't be designed
• How add a Column In DataGridView
• adding data to comboBox
• Cannot open Designer
• There is already a command handler for the menu command '5efc7975-14bc-11cf-9b2b-00aa00573819 : 17'
• Prevent my Component from appearing in component tray?
• Data-binding problems at design time (VS 2005)
• Binary serialization
• Problems with localized Usercontrol
• more than one value in listbox