Back to Devexpress

RepositoryItemPopupBase.CustomizeContextItem Event

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitempopupbase-1c3ed804.md

latest3.2 KB
Original Source

RepositoryItemPopupBase.CustomizeContextItem Event

Allows you to customize the context buttons for individual items.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Context Buttons")]
public event ListBoxControlContextButtonCustomizeEventHandler CustomizeContextItem
vb
<DXCategory("Context Buttons")>
Public Event CustomizeContextItem As ListBoxControlContextButtonCustomizeEventHandler

Event Data

The CustomizeContextItem event's data class is DevExpress.XtraEditors.ViewInfo.ListBoxControlContextButtonCustomizeEventArgs.

Remarks

By default, the popup editor displays the context buttons with the same properties in all items. The CustomizeContextItem event fires for each context button in each item before the editor is displayed and allows you to customize the context buttons. Read the ListBoxControlContextButtonCustomizeEventArgs.Item property to determine the item being processed. The ListBoxControlContextButtonCustomizeEventArgs.ContextItem property returns the context button to be customized.

The code snippet below shows how to provide the custom appearance setting for a particular item of the ComboBoxEdit.

csharp
private void comboBoxEdit1_Properties_CustomizeContextItem(object sender, DevExpress.XtraEditors.ViewInfo.ListBoxControlContextButtonCustomizeEventArgs e) {
    RatingContextButton rcb = e.ContextItem as RatingContextButton;
    if(rcb != null) {
        String item = e.Item as String;
        if(item != null && item == "California") {
            rcb.AppearanceNormal.ForeColor = Color.Red;
        }
    }
}
vb
Private Sub comboBoxEdit1_Properties_CustomizeContextItem(sender As Object, e As DevExpress.XtraEditors.ViewInfo.ListBoxControlContextButtonCustomizeEventArgs)
    Dim rcb As RatingContextButton = TryCast(e.ContextItem, RatingContextButton)
    If rcb IsNot Nothing Then
        Dim item As [String] = TryCast(e.Item, [String])
        If item IsNot Nothing AndAlso item = "California" Then
            rcb.AppearanceNormal.ForeColor = Color.Red
        End If
    End If
End Sub

The result is shown below.

See Also

ContextButtons

RepositoryItemPopupBase Class

RepositoryItemPopupBase Members

DevExpress.XtraEditors.Repository Namespace