Customizing C1Toolbar Items in WinForms
More often we receive queries in WinForms regarding the customization of C1Toolbar control. Since C1Toolbar does not provide extensive properties or methods for customizations, queries are mostly related to changing the appearance of the toolbar items. In this blog we look forward to a small implementation which uses DrawLink event for C1Toolbar. This event fires for each Toolbar item, whose 'OwnerDraw' property is set to true. So based on our requirement, you can set the 'OwnerDraw' property to true for either all or specific toolbar items which need to be customized. To show the implementation, we will implement the following customizations.
- Draw Border around C1ToolbarItem
- Use Red color as ForegroundColor
- Reduce the gap between the Image and the Text
Setting OwnerDraw Property
Set the 'OwnerDraw' property of C1CommandLink objects to True for all the Toolbar items which you wish to customize. You can do this both in designer and through code.
Customizing C1ToolBarItem
We can change the appearance of the toolbar item such that the default MouseHover implementation effect does not change. The DrawLink event is fired even when Mouse is hovered over the toolbar item. By keeping track of the cursor position, we can apply the customization on the toolbar item.
It's a very simple implementation. You can make use of this event to customize the toolbar to a lot extent. For complete implementation, refer to the attached samples. Download C# Sample Download VB Sample