Back to Devexpress

CustomProperties.SetValue(String, String, Boolean) Method

dashboard-devexpress-dot-dashboardcommon-dot-customproperties-dot-setvalue-x28-system-dot-string-system-dot-string-system-dot-boolean-x29.md

latest9.9 KB
Original Source

CustomProperties.SetValue(String, String, Boolean) Method

Records or clears a custom property value. This method doesn’t save your action to the Dashboard Designer’s history.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public void SetValue(
    string propertyName,
    string propertyValue,
    bool raiseCustomPropertyChanged = true
)
vb
Public Sub SetValue(
    propertyName As String,
    propertyValue As String,
    raiseCustomPropertyChanged As Boolean = True
)

Parameters

NameTypeDescription
propertyNameString

A String that specifies a custom property name.

| | propertyValue | String | |

Optional Parameters

NameTypeDefaultDescription
raiseCustomPropertyChangedBooleanTrue

true to raise the DashboardCustomPropertyChanged event; otherwise, false.

|

Remarks

You can add a new property or update an existing property’s value in the dashboard definition. Custom properties are stored in the CustomProperties collection in a structured format. Each custom property in this collection contains the custom property’s unique name and value.

The following table lists the levels and corresponding properties used to access the collection at this level:

Level to applyDescriptionPropertyExample
DashboardStores custom data related to the dashboard.Dashboard.CustomPropertiesDashboard description
Dashboard itemStores custom data related to a particular dashboard item.DashboardItem.CustomPropertiesChart Item - Scale Breaks
Chart Item - Constant Line
Data item containerStores custom data related to the Grid’s columns, the Chart’s series and other elements of a dashboard item.DataItemContainer.CustomPropertiesGrid Item - Fixed (Pinned) Columns

The code snippet below saves a new value for the DashboardDescription property:

csharp
designer.Dashboard.CustomProperties.SetValue("DashboardDescription", "New custom description");
vb
designer.Dashboard.CustomProperties.SetValue("DashboardDescription", "New custom description")

The custom property’s value is stored as a string. For example, a dashboard XML file stores the DashboardDescription property at the dashboard’s level. The property’s value is used as the dashboard’s description.

xml
<Dashboard>
...
    <CustomProperties>
        <DashboardDescription>This dashboard shows statistics on sales of bicycles, related equipment and accessories. ...</DashboardDescription>
    </CustomProperties>
</Dashboard>

To clear a custom property value, pass null to the CustomProperties.SetValue method.

The following code snippet clears the value of the DashboardDescription property:

csharp
designer.Dashboard.CustomProperties.SetValue("DashboardDescription", null);
vb
designer.Dashboard.CustomProperties.SetValue("DashboardDescription", Nothing)

Refer to the Create Custom Properties article for details.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetValue(String, String, Boolean) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-save-restore-dashboard-state/CS/WinFormsDashboard_DashboardState/Form1.cs#L58

csharp
var stateValue = state.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardViewer1.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
dashboardViewer1.Dashboard.SaveToXml(path);

winforms-designer-save-and-apply-dashboard-state/CS/WinDesignerDashboardState/DesignerForm1.cs#L35

csharp
var stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardDesigner.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
dashboardDesigner.Dashboard.SaveToXml(path);

wpf-dashboard-how-to-set-initial-dashboard-state/CS/WpfDashboard_DashboardState/MainWindow.xaml.cs#L42

csharp
var stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardControl.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
dashboardControl.Dashboard.SaveToXml("SampleDashboardWithState.xml");

winforms-viewer-save-and-apply-dashboard-state/CS/WinFormsViewerSaveAndApplyDashboarState/ViewerForm1.cs#L36

csharp
var stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting);
dashboardViewer.Dashboard.CustomProperties.SetValue("DashboardState", stateValue);
dashboardViewer.Dashboard.SaveToXml(path);

winforms-dashboard-save-restore-dashboard-state/VB/WinFormsDashboard_DashboardState/Form1.vb#L49

vb
Dim stateValue = state.SaveToXml().ToString(SaveOptions.DisableFormatting)
dashboardViewer1.Dashboard.CustomProperties.SetValue("DashboardState", stateValue)
dashboardViewer1.Dashboard.SaveToXml(path)

winforms-designer-save-and-apply-dashboard-state/VB/WinDesignerDashboardState/DesignerForm1.vb#L34

vb
Dim stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting)
dashboardDesigner.Dashboard.CustomProperties.SetValue("DashboardState", stateValue)
dashboardDesigner.Dashboard.SaveToXml(path)

wpf-dashboard-how-to-set-initial-dashboard-state/VB/WpfDashboard_DashboardState/MainWindow.xaml.vb#L36

vb
Dim stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting)
dashboardControl.Dashboard.CustomProperties.SetValue("DashboardState", stateValue)
dashboardControl.Dashboard.SaveToXml("SampleDashboardWithState.xml")

winforms-viewer-save-and-apply-dashboard-state/VB/WinFormsViewerSaveAndApplyDashboarState/ViewerForm1.vb#L35

vb
Dim stateValue = dState.SaveToXml().ToString(SaveOptions.DisableFormatting)
dashboardViewer.Dashboard.CustomProperties.SetValue("DashboardState", stateValue)
dashboardViewer.Dashboard.SaveToXml(path)

See Also

CustomProperties Class

CustomProperties Members

DevExpress.DashboardCommon Namespace