Back to Devexpress

RepositoryItemLookUpEdit.CustomDrawCell Event

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemlookupedit.md

latest2.5 KB
Original Source

RepositoryItemLookUpEdit.CustomDrawCell Event

Provides the capability to perform custom painting of grid cells in the drop-down.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event LookUpCustomDrawCellEventHandler CustomDrawCell
vb
<DXCategory("Events")>
Public Event CustomDrawCell As LookUpCustomDrawCellEventHandler

Event Data

The CustomDrawCell event's data class is DevExpress.XtraEditors.Popup.LookUpCustomDrawCellArgs.

Remarks

The CustomDrawCell event fires each time a grid cell in the drop-down is about to be painted, and allows you to specify custom appearance settings or perform custom painting.

The code snippet below shows how to set a custom background color for cells in odd rows.

csharp
void rtLookUpEdit_CustomDrawCell(object sender, DevExpress.XtraEditors.Popup.LookUpCustomDrawCellArgs e) {
    if (e.IsRowSelected) return;
    if ((e.RowIndex % 2) == 0) return;
    e.Appearance.BackColor = Color.LightGray;
}
vb
Private Sub rtLookUpEdit_CustomDrawCell(sender As Object, e As DevExpress.XtraEditors.Popup.LookUpCustomDrawCellArgs)
    If e.IsRowSelected Then
        Return
    End If
    If (e.RowIndex Mod 2) = 0 Then
        Return
    End If
    e.Appearance.BackColor = Color.LightGray
End Sub

The figure below shows the result.

You can also perform custom cell painting using the Graphics argument. Note that the Handled argument must be set to true in this case to prevent the default painting.

See Also

CustomDrawCell

RepositoryItemLookUpEdit Class

RepositoryItemLookUpEdit Members

DevExpress.XtraEditors.Repository Namespace