BaseGallery.CustomDrawItemText Event
Enables the Gallery item’s text to be painted manually.
Namespace: DevExpress.XtraBars.Ribbon.Gallery
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Event Data
The CustomDrawItemText event's data class is GalleryItemCustomDrawEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Bounds | Gets the bounding rectangle of the Gallery item currently being painted. |
Cache | Gets an object which specifies the storage for the most used pens, fonts and brushes. |
Gallery | Gets the Gallery that contains the processed Gallery item. Inherited from GalleryItemEventArgs. |
Handled | Gets or sets whether an event was handled. If it was handled default painting isn’t required. |
InRibbonGalleryLink | For In-Ribbon galleries, gets the bar item link that displays the current gallery. Inherited from GalleryItemEventArgs. |
Item | Gets the Gallery item currently being processed. Inherited from GalleryItemEventArgs. |
ItemInfo | Gets the information which is required to paint a Gallery item. |
The event data class exposes the following methods:
Method | Description |
---|---|
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements. |
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. |
Remarks
The CustomDrawItemText event is raised each time an item’s text is about to be painted. The event parameter provides all the information necessary to paint the text. Set the Handled property to true to prohibit default text painting.
Example
In this example the BaseGallery.CustomDrawItemText
event is handled to manually paint the text within Gallery items.
The full source code can be found in the ‘Ribbon Simple Pad’ demo supplied with the XtraBars.
The image below shows the result:
using DevExpress.XtraBars.Ribbon.ViewInfo;
private void gddFont_Gallery_CustomDrawItemText(object sender, GalleryItemCustomDrawEventArgs e) {
DevExpress.XtraBars.Ribbon.ViewInfo.GalleryItemViewInfo itemInfo = e.ItemInfo as DevExpress.XtraBars.Ribbon.ViewInfo.GalleryItemViewInfo;
itemInfo.PaintAppearance.ItemDescriptionAppearance.Normal.DrawString(e.Cache, e.Item.Description, itemInfo.DescriptionBounds);
AppearanceObject app = itemInfo.PaintAppearance.ItemCaptionAppearance.Normal.Clone() as AppearanceObject;
app.Font = (Font)e.Item.Tag;
try {
e.Cache.DrawString(e.Item.Caption, app.Font, app.GetForeBrush(e.Cache), itemInfo.CaptionBounds);
}
catch { }
e.Handled = true;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawItemText event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.