Tuesday, January 12, 2016

How to export XtraGrid to excel with cell and row styles?

Scenario:

In current implementation, I have applied custom style using the GridView_RowCellStyle event e.g. text formatting and background color. Then I was trying to export the grid to excel file but all of the applied styles lost.

Solution:

To solve this problem which was looking huge by doing a small correction in implementation in never version of DevExpress controls. I set the DevExpress.Export.ExportSettings.DefaultExportType property to WYSIWYG and tried to export it again. Now I found all the changes as I have applied through customization.

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