开发者

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.

Transparency in composite controls?


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:`

  1. ChildButton exists.
  2. ChildButton is a member of CompositeControl.Controls.
  3. ChildButton location is 'in-view' of the CompositeControl.
  4. 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))]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜