How to show Control only when fully created (.NET)
I'm creating complex UserControl, what is annoying to me is application shows it partially during creation mode.
Means end user can see all creation / draw process (controls placed on this UserControl appearing with delay, gradient boxes draw they fill etc)I'm pretty sure there is some command hiding this process and showing control only when it is fully drawn...
Can someone ad开发者_如何学Govice how to archive that?
Ensure that your UserControl has been marked to be double buffered. This ensures that when the client area of the UserControl needs drawing it is done so onto an off-screen buffer and then when completed it is blitted to the screen. This makes it atomic and you should not see drawing actions as they occur. To add this use the following in your UserControl constructor...
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint, true);
Mhh I don't think exist something exactly like this, but there are these things:
- SuspendLayout (This does what you want, doesn't show the drawing process, ResumeLayout to show layout changes)
- Visible (you can change it when drawing control)
- Paint event
You can also call Invalidate (which force redrawing of the form)
This works for initialization quite well, but I don't understand if you want it every time the control is painted or only when is created
However I don't have an idea on how to intercept "before drawing" and "after drawing" (Paint I think it's triggered before drawing, not sure)
精彩评论