I am working on a custom status strip in which i have overridden the OnBackgroundPaint event however there is about a 5 - 7px area to the far right of the status strip that is not painted. I assume this is a certain area that I am missing and needs custom painting but I am not sure what it is. Possibly the resize handle? Is there anyway to simply turn that off so that it doesn't show up at all or if it cannot be turned off is there a way to paint it so that the statusstrip will look consistent across the full length?
Thanks,
Matt |
| KarmaKid15 Thursday, October 01, 2009 3:40 PM |
Hmm, not that likely. The sizing grip is exact 12 pixels wide. You should assign the Renderer property to implement custom rendering: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.statusStrip1.Renderer = new MyRenderer(); } private class MyRenderer : ToolStripProfessionalRenderer { protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { // Do your thing... } } }
Hans Passant.- Proposed As Answer byWang, JieMSFTWednesday, October 07, 2009 2:00 AM
- Marked As Answer byKarmaKid15 Wednesday, October 07, 2009 2:24 PM
-
|
| nobugz Thursday, October 01, 2009 7:10 PM |
Hmm, not that likely. The sizing grip is exact 12 pixels wide. You should assign the Renderer property to implement custom rendering: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.statusStrip1.Renderer = new MyRenderer(); } private class MyRenderer : ToolStripProfessionalRenderer { protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { // Do your thing... } } }
Hans Passant.- Proposed As Answer byWang, JieMSFTWednesday, October 07, 2009 2:00 AM
- Marked As Answer byKarmaKid15 Wednesday, October 07, 2009 2:24 PM
-
|
| nobugz Thursday, October 01, 2009 7:10 PM |
Hi Matt, nobugz is right. When dealing with ToolStrip controls, we use renders to custom draw. See: How to: Custom Draw a ToolStrip ControlRegards, Jie MSDN Subscriber Support in Forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have any feedback, please tell us.
The CodeFx Project
My Blog (in Simplified Chinese) |
| Wang, Jie Friday, October 02, 2009 9:40 AM |
Thanks, this did get rid of the area mentioned above however I noticed that my dividers are now missing. Do I have to override code for everything in the status strip to ensure that it is drawn?
Also as a side question, when using a progress bar I've noticed that when using the "continuous" mode of operation which is supposed to display a smooth connected progress it still displays as blocks... Is there something I am doing wrong? |
| KarmaKid15 Wednesday, October 07, 2009 2:25 PM |
You get blocks in the PB when visual styles are disabled. This is normally taken care of by the Application.EnableVisualStyles() call in Main(). If it's there and you still get blocks then there's probably something wrong with your machine. This affects the default status strip painting as well.
Hans Passant. |
| nobugz Wednesday, October 07, 2009 2:32 PM |
Thanks, as for the seperators in the StatusStrip, why aren't they showing up? Also if it is required that I paint them could you provide an example code of how to do so? The seperators i'm talking about are really the borders of the controls contained in the status strip. For instance <control>.BorderStyle = RaisedInner. Those aren't showing up now? |
| KarmaKid15 Wednesday, October 07, 2009 2:57 PM |
I don't know, I can't see your screen from here. Make a small project that reproduces your problem and post it to a file sharing service.
Hans Passant. |
| nobugz Wednesday, October 07, 2009 3:26 PM |