Wednesday, January 6, 2016

How to disable path editing in BreadCrumbEdit control?

Recently I have implemented DevExpress BreadCrumbEdit control in my application and in the implementation I need to disable editing of the path in the control. In technical words, I need BreadCrumbEdit control in only Select mode rather the Edit Mode. Initially it can be set using the BreadCrumbEdit’s BreadCrumbMode property to “Select”.

I found one solution that it is impossible to prevent switching to the Edit mode. The easiest way DevExpress guys suggest that handle the BreadCrumbEdit's PropertiesChanged event and reset it back to “Select” if it try to go in the “Edit” mode. So I did it in the following manner:

C#

private void breadCrumbEdit1_PropertiesChanged(object sender, EventArgs e)
{
    if (breadCrumbEdit1.Properties.BreadCrumbMode == BreadCrumbMode.Edit)
    {
        breadCrumbEdit1.Properties.BreadCrumbMode = BreadCrumbMode.Select;
    }
}

VB
Private Sub breadCrumbEdit1_PropertiesChanged(sender As Object, e As EventArgs)
    If breadCrumbEdit1.Properties.BreadCrumbMode = BreadCrumbMode.Edit Then
        breadCrumbEdit1.Properties.BreadCrumbMode = BreadCrumbMode.Select
    End If
End Sub

No comments :

Post a Comment