Skip to main content

RepositoryItemLookUpEdit.CustomDrawLine Event

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

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event LookUpCustomDrawLineEventHandler CustomDrawLine

Event Data

The CustomDrawLine event's data class is DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs.

Remarks

If the RepositoryItemLookUpEdit.ShowLines property is set to true, vertical lines separating the grid columns (see RepositoryItemLookUpEdit.Columns) are displayed in the drop-down.

By default, the line appearance depends on the skin settings, if applied; or otherwise, on the system settings. The CustomDrawLine event fires each time the drop-down is about to be painted, and allows you specify custom appearance settings or perform custom painting of vertical grid lines in the drop-down.

You can specify custom appearance settings using the event arguments’ Apperance property. The code snippet below shows how to specify a custom color for the vertical grid lines.

private void lookUpEdit1_CustomDrawLine(object sender, DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs e) {
     e.Appearance.ForeColor = Color.Red;
 }

The result is shown below.

LookUpEdit_CustomDrawLineAppearance

You can also provide custom painting of the lines using the Graphics object accessible through the arguments’ Cache property. The code snippet below shows how to draw the grid lines with a custom color and dash style. Note that the arguments’ Handled property must be set to true to prevent the default painting.

private void Edit_CustomDrawLine(object sender, DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs e) {
    using(Pen p = new Pen(Color.Red)) {
        p.DashStyle = DashStyle.DashDot;
        e.Cache.DrawLine(p,
            new Point(e.Bounds.X, e.Bounds.Y),
            new Point(e.Bounds.X, e.Bounds.Bottom)
            );
    }
    e.Handled = true;
}

The figure below shows the result.

LookUpEdit_CustomDrawLine

See Also