Gets or sets whether the buttons on this band are drawn using your own custom code.
One of the ButtonDrawMode values. The default is ButtonDrawMode.Normal.
Rebar buttons can be drawn by the control or by the user of the control. The DrawMode property allows users of the control to customize the way that the bands are drawn. When the value of this property is OwnerDraw, the DrawButton event is raised when a button needs to be drawn. When the value is OwnerDrawAndMeasure, the MeasureButton event is also raised when a button's width needs to be determined.
Exception Type | Condition |
---|---|
InvalidEnumArgumentException | The assigned value is not one of the ButtonDrawMode values. |
This example handles the DrawButton event of a rebar band whose DrawMode property is set to OwnerDraw. The buttons are drawn using the Microsoft Office XP style.
private void rebarBand1_DrawButton(object sender, Skybound.Rebar.DrawButtonEventArgs e) { // invoke default implementation for separators: if (e.Renderer.ButtonType == RebarButtonType.Separator) { e.Renderer.RenderButton(e.Graphics); } else { // highlight the border and background when the button is hot or pushed if (e.Renderer.State != RebarButtonState.Normal || e.Renderer.Checked) { // get button bounds: Rectangle buttonBounds = e.Renderer.Bounds; // size of bounds must be reduced by 1 for DrawRectangle: buttonBounds.Size -= new Size(1, 1); // fill background: using (SolidBrush brush = new SolidBrush(Color.FromArgb(64, SystemColors.Highlight))) e.Graphics.FillRectangle(brush, buttonBounds); // draw border: e.Graphics.DrawRectangle(SystemPens.Highlight, buttonBounds); // draw menu button borders: if (e.Renderer.ButtonType == RebarButtonType.MenuOrPush) { Rectangle dropDown = e.Renderer.GetDropDownRectangle(); dropDown.Size -= new Size(1, 1); e.Graphics.DrawRectangle(SystemPens.Highlight, dropDown); } } // invoke default implementation for image, text and arrow: e.Renderer.DrawImage(e.Graphics); e.Renderer.DrawText(e.Graphics); e.Renderer.DrawArrow(e.Graphics); } }
RebarBand Class | Skybound.Rebar Namespace