Custom Splitbuttons, Arrow lost.

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2009
Posts: 4
Reputation: phantom8l is an unknown quantity at this point 
Solved Threads: 0
phantom8l phantom8l is offline Offline
Newbie Poster

Custom Splitbuttons, Arrow lost.

 
0
  #1
Sep 29th, 2009
Hey everyone im trying to finish up my custom renderers for menustrip toolstrip and statusstrip but when i override the OnRenderSplitButtonBackground the dropdown arrow dissapears here is my code

  1. protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
  2. {
  3. if (e.Item.Selected)
  4. {
  5.  
  6. Rectangle rectBorder = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
  7. Rectangle rect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
  8. LinearGradientBrush b = new LinearGradientBrush(rect, clsClrs.clrSelectedBG_White, clsClrs.clrSelectedBG_Header_Blue, LinearGradientMode.Vertical);
  9.  
  10. GraphicsPath path = new GraphicsPath();
  11. path = clsClrs.FillRoundedRectangle(e.Graphics, rect.X, rect.Y, rect.Width, rect.Height, 8);
  12.  
  13. e.Graphics.FillPath(b, path);
  14. clsClrs.DrawRoundedRectangle(e.Graphics, rectBorder.X, rectBorder.Y, rectBorder.Width, rectBorder.Height, 8, clsClrs.clrToolstripBtn_Border);
  15. }
  16.  
  17. //base.OnRenderSplitButtonBackground(e);
  18. }

I cant seem to figure out how to get back, anyone can help me? thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 254
Reputation: Antenka has a spectacular aura about Antenka has a spectacular aura about Antenka has a spectacular aura about 
Solved Threads: 65
Antenka's Avatar
Antenka Antenka is offline Offline
Posting Whiz in Training

Re: Custom Splitbuttons, Arrow lost.

 
0
  #2
Sep 29th, 2009
Hello, phantom8l.
This can be interesting for you: Manually painting a ToolStripSplitButton
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 352
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 44
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: Custom Splitbuttons, Arrow lost.

 
0
  #3
Sep 29th, 2009
very simple solution, just use GDI+ to draw a new arrow

at the end just throw in

//e.Graphics.FillPolygon(Brushes.Black, new Point[]{new Point(x, y), new Point(x, y), new Point(x,y)});

specify the points as needed. since you only pass 3 points you get a triangle, if two points have the same Y value, and the third point's x value is half way between the first 2 X values then you get a downward facing arrow, which I think is what you want.

now Im not sure what look you were going for so I didn't put in any values here, but I am sure if you are custom drawing your own controls you will be able to figure out the points yourself.

Best of luck.


Alternatively, the actual reason that the arrow isn't drawn is because you override the method that calls the method that draws it. called "drawarrow" from the base class, here is an excerpt from the code on the link that Antenka posted above me.

  1. class MyRender : ToolStripRenderer
  2. {
  3. protected override void
  4. OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
  5. {
  6. base.OnRenderSplitButtonBackground(e);
  7. ToolStripSplitButton item = e.Item as ToolStripSplitButton;
  8. base.DrawArrow(new
  9. ToolStripArrowRenderEventArgs(e.Graphics, item, item.DropDownButtonBounds,
  10. SystemColors.ControlText, ArrowDirection.Down));
  11. }
  12. }
Last edited by Diamonddrake; Sep 29th, 2009 at 4:43 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: phantom8l is an unknown quantity at this point 
Solved Threads: 0
phantom8l phantom8l is offline Offline
Newbie Poster

Re: Custom Splitbuttons, Arrow lost.

 
0
  #4
Sep 29th, 2009
Originally Posted by Antenka View Post
Hello, phantom8l.
This can be interesting for you: Manually painting a ToolStripSplitButton
ahhh-ha thats exactly what i was looking for thank you for taking the time to search for that for me, i tried searching everywhere but couldnt describe what i was lookin for also thanks for the very fast reply
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 254
Reputation: Antenka has a spectacular aura about Antenka has a spectacular aura about Antenka has a spectacular aura about 
Solved Threads: 65
Antenka's Avatar
Antenka Antenka is offline Offline
Posting Whiz in Training

Re: Custom Splitbuttons, Arrow lost.

 
0
  #5
Sep 29th, 2009
Hehe .. you're welcome.

Please, mark this thread as "solved" if you got the answer on your question
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 4
Reputation: phantom8l is an unknown quantity at this point 
Solved Threads: 0
phantom8l phantom8l is offline Offline
Newbie Poster

Re: Custom Splitbuttons, Arrow lost.

 
0
  #6
Sep 29th, 2009
thanks also diamonddrake for the quick reply but i prefer the solution antenka found because i do not need to draw a whole new arrow i just call base.drawarrow and presto fresh arrow
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 352
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 44
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: Custom Splitbuttons, Arrow lost.

 
0
  #7
Sep 29th, 2009
Originally Posted by phantom8l View Post
thanks also diamonddrake for the quick reply but i prefer the solution antenka found because i do not need to draw a whole new arrow i just call base.drawarrow and presto fresh arrow
yeah. its a much simpler solution.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 462 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC