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

protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            if (e.Item.Selected)
            {

                Rectangle rectBorder = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                Rectangle rect = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                LinearGradientBrush b = new LinearGradientBrush(rect, clsClrs.clrSelectedBG_White, clsClrs.clrSelectedBG_Header_Blue, LinearGradientMode.Vertical);

                GraphicsPath path = new GraphicsPath();
                path = clsClrs.FillRoundedRectangle(e.Graphics, rect.X, rect.Y, rect.Width, rect.Height, 8);

                e.Graphics.FillPath(b, path);
                clsClrs.DrawRoundedRectangle(e.Graphics, rectBorder.X, rectBorder.Y, rectBorder.Width, rectBorder.Height, 8, clsClrs.clrToolstripBtn_Border);
            }
            
            //base.OnRenderSplitButtonBackground(e);
        }

I cant seem to figure out how to get back, anyone can help me? thanks

Recommended Answers

All 6 Replies

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([I]x, y[/I]), new Point([I]x, y[/I]), new Point([I]x,y[/I])});

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.

class MyRender : ToolStripRenderer
{
protected override void
OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
{
base.OnRenderSplitButtonBackground(e);
ToolStripSplitButton item = e.Item as ToolStripSplitButton;
base.DrawArrow(new
ToolStripArrowRenderEventArgs(e.Graphics, item, item.DropDownButtonBounds,
SystemColors.ControlText, ArrowDirection.Down));
}
}

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

Hehe .. you're welcome.

Please, mark this thread as "solved" if you got the answer on your question :)

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.