Back to Devexpress

RepositoryItemLookUpEdit.CustomDrawLine Event

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

latest4.1 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

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

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.

csharp
private void lookUpEdit1_CustomDrawLine(object sender, DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs e) {
     e.Appearance.ForeColor = Color.Red;
 }
vb
Private Sub lookUpEdit1_CustomDrawLine(sender As Object, e As DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs)
    e.Appearance.ForeColor = Color.Red
End Sub

The result is shown below.

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.

csharp
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;
}
vb
Private Sub Edit_CustomDrawLine(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Popup.LookUpCustomDrawLineArgs)
    Using p As 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))
    End Using
    e.Handled = True
End Sub

The figure below shows the result.

See Also

ShowLines

Columns

RepositoryItemLookUpEdit Class

RepositoryItemLookUpEdit Members

DevExpress.XtraEditors.Repository Namespace