943,582 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 1133
  • C# RSS
Sep 29th, 2009
0

Custom Splitbuttons, Arrow lost.

Expand Post »
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

C# Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phantom8l is offline Offline
4 posts
since Sep 2009
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

Hello, phantom8l.
This can be interesting for you: Manually painting a ToolStripSplitButton
Reputation Points: 293
Solved Threads: 82
Posting Whiz
Antenka is offline Offline
361 posts
since Nov 2008
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

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.

C# Syntax (Toggle Plain Text)
  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.
Reputation Points: 442
Solved Threads: 89
Master Poster
Diamonddrake is offline Offline
721 posts
since Mar 2008
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

Click to Expand / Collapse  Quote originally posted by Antenka ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phantom8l is offline Offline
4 posts
since Sep 2009
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

Hehe .. you're welcome.

Please, mark this thread as "solved" if you got the answer on your question
Reputation Points: 293
Solved Threads: 82
Posting Whiz
Antenka is offline Offline
361 posts
since Nov 2008
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phantom8l is offline Offline
4 posts
since Sep 2009
Sep 29th, 2009
0

Re: Custom Splitbuttons, Arrow lost.

Click to Expand / Collapse  Quote originally posted by phantom8l ...
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.
Reputation Points: 442
Solved Threads: 89
Master Poster
Diamonddrake is offline Offline
721 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: dataGridView.ClearSelection Except current cell
Next Thread in C# Forum Timeline: Control of UserControl components from another form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC