Back to Devexpress

ContextItemCollection.Add(ContextItem) Method

windowsforms-devexpress-dot-utils-dot-contextitemcollection-dot-add-x28-devexpress-dot-utils-dot-contextitem-x29.md

latest4.1 KB
Original Source

ContextItemCollection.Add(ContextItem) Method

Adds a ContextItem to a ContextItemCollection.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public int Add(
    ContextItem item
)
vb
Public Function Add(
    item As ContextItem
) As Integer

Parameters

NameTypeDescription
itemContextItem

A ContextItem to be added to a ContextItemCollection.

|

Returns

TypeDescription
Int32

A ContextItem‘s index in the collection.

|

Remarks

The code below demonstrates how to add a new RatingContextButton to a ContextItemCollection.

csharp
using DevExpress.Utils;
// ...
pictureEdit1.Properties.ContextButtons.Add(new RatingContextButton());
vb
Imports DevExpress.Utils
' ...
pictureEdit1.Properties.ContextButtons.Add(New RatingContextButton())

The picture below demonstrates the result.

To set the ContextItem apart from the background, you may need to adjust ContextItemCollectionOptions, for example, TopPanelColor or BottomPanelColor.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(ContextItem) method.

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.

winforms-calendar-dateedit-cell-appearance-customization/CS/Calendar_CellStyleProvider/Form1.cs#L29

csharp
calendarControl1.CellSize = new Size(50, 50);
calendarControl1.ContextButtons.Add(cb);
calendarControl1.ContextButtonCustomize += CalendarControl1_ContextButtonCustomize;

winforms-calendar-dateedit-cell-appearance-customization/VB/Calendar_CellStyleProvider/Form1.vb#L30

vb
calendarControl1.CellSize = New Size(50, 50)
calendarControl1.ContextButtons.Add(cb)
AddHandler calendarControl1.ContextButtonCustomize, AddressOf CalendarControl1_ContextButtonCustomize

See Also

ContextItemCollection Class

ContextItemCollection Members

DevExpress.Utils Namespace