Le réseau pour les développeurs >
Forums - Accueil
>
Windows Forms General
>
Do not refresh User Control
Do not refresh User Control
- Hey,Is it possible to command a user control to not refresh unless called by code written by me? This is because I have a User Control called a DateBar, which has many child User Controls called Tasks and another child User Control called an ArrowPanel. When the date bar is refreshed, first I want it to refresh itself, then the Tasks, and finally the ArrowPanel. It has to be in this order, but it currently is not doing that. I also think that the problem may lie in the fact that the ArrowPanel contains the following code:From what I gather, when this code is executed, it redraws the parent control, and thus the Tasks (although I'm not sure). Also making it very slow.
protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x00000020;//WS_EX_TRANSPARENT return cp; } } protected override void OnPaintBackground(PaintEventArgs e) { Color bk = Color.FromArgb(0, this.BackColor); e.Graphics.FillRectangle(new SolidBrush(bk), e.ClipRectangle); }
Is there anyway around this?To explain what the ArrowPanel is doing: It is basically there to be ontop of all of the Tasks so that it can be passed coordinates between which to draw lines. So, it makes itself "transparent" using the code above. I was wondering if instead, what would be better, would be if I were to use Windows API or something like that to draw the lines ontop of the form rather than on a UserControl.Thanks very much and any input is much appreciated,,,Matt- DéplacéTaylorMichaelLMVPjeudi 5 novembre 2009 18:49WinForms related (From:Visual C# General)
Réponses
- this.SuspendLayout()then when you want it to paint againthis.ResumeLayout(true)
If this answers your question, please mark the question as answered.- Marqué comme réponseLing WangMSFT, Moderatorjeudi 12 novembre 2009 09:55
- Not certain what you are after.
You can draw on one object at a time. That's how it works.
Overlay something over the form and draw on that. Looks and appearance is all that matters.
Mark the best replies as answers. "Fooling computers since 1971."- Marqué comme réponseLing WangMSFT, Moderatorjeudi 12 novembre 2009 09:55
Toutes les réponses
- this.SuspendLayout()then when you want it to paint againthis.ResumeLayout(true)
If this answers your question, please mark the question as answered.- Marqué comme réponseLing WangMSFT, Moderatorjeudi 12 novembre 2009 09:55
- Thanks,,, if I say this.SuspendLayout(), can I then say this.refresh() and have it refresh without saying this.ResumeLayout(true)?thanks,,,Matt
- Nope. Calling SuspendLayout does just that, it ignores all calls to Refresh until you call ResumeLayout.
If this answers your question, please mark the question as answered. - Ok,,, well I don't think that this is the method that I would like to pursue as I think that it makes it overly complicated. Is there anyway that I could make the DateBar draw over its children? Or is there anyway that I can easily draw over the top of DateBar and its children without using a UserControl?Thanks,,,Matt
- Why don't you just call the methods explicitly on the controls you want in the order that you want?
Sorry, I would love to answer stuff about your custom control, but we just don't know enough about it.
Mark the best replies as answers. "Fooling computers since 1971." - Ok, thanks,,,But just out of interest, is there anyway that I can draw on top of all the controls on a form?Thanks,,,Matt
- Not certain what you are after.
You can draw on one object at a time. That's how it works.
Overlay something over the form and draw on that. Looks and appearance is all that matters.
Mark the best replies as answers. "Fooling computers since 1971."- Marqué comme réponseLing WangMSFT, Moderatorjeudi 12 novembre 2009 09:55
- Ok,,, I was thinking along the lines of ControlPaint. Because that allows you to draw anywhere on the screen (even outside the form). I wanted somehing like this but I can only draw in th selected form. Is this not possible, thanks,,, Matt ps I fixed th original problem. Wasn't what I thought it was. Thanks for the help anyway :)

