Transparency in composite controls?
I have a composite control that is includes a groupbox control. The problem is it covers the controls that are placed on top of this composite control. Even though I send the new controls to top, so they should be visible, but they aren't.
When I just use the groupbox, of course it shows through things so you see the included controls, just outlined by the groupbox.
Should I have to do something to get the same effect/behaviou开发者_如何学Pythonr in a composite control?
EDIT: Left side shows the control in the designer, right side shows the control at runtime.
It is possible Quintin is right, and that something is going wrong with the designer support of your control, that is, you've created ControlA, and are extending it to ControlB by adding a button at design time. When you instatiate ControlB, the button is not visible.
Can you verify at runtime, using breakpoints/asserts/etc that:`
ChildButton
exists.ChildButton
is a member ofCompositeControl.Controls
.ChildButton
location is 'in-view' of theCompositeControl
.ChildButton
is visible.
If it were me, I'd set a breakpoint in the constructor of the control, and ride into InitializeComponent()
, checking that everything is created and added correctly. If ChildButton
exists, and has a reference in CompositeControl.Controls
and its location is in-view, then I'm at a loss to explain why it's not showing.
If you are meaning that you would like the custom control to behave like a container (like a groupbox normally does) then you need to let the control and the designer know how it should be treated.
Remember to implement IContainerControl
and decorate the object with the appropriate designer attribute for designer container support IE:
[Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design", typeof(System.ComponentModel.Design.IDesigner))]
精彩评论