Back to Devexpress

EditOptions.ReadOnly Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-editoptions-efd2133d.md

latest3.2 KB
Original Source

EditOptions.ReadOnly Property

Specifies whether an editor for customizing a control’s content in Print Preview is enabled.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[DefaultValue(false)]
public bool ReadOnly { get; set; }
vb
<DefaultValue(False)>
Public Property [ReadOnly] As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true , to prohibit editing a control’s content in Print Preview; otherwise, false.

|

Remarks

You can enable content editing for a report control by setting the EditOptions.Enabled property to true. This results in one or more corresponding editing fields being added to the PrintingSystemBase.EditingFields collection.

When the ReadOnly property is enabled, a corresponding field cannot be edited in Print Preview and is not highlighted as an editing field. The following code illustrates how to use this property to disable content editing for a specific user.

csharp
using DevExpress.XtraPrinting;
// ...

private void XtraReport1_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    PrintingSystem.AfterBuildPages += PrintingSystem_AfterBuildPages;
}

private static string userName = System.Environment.UserName;

void PrintingSystem_AfterBuildPages(object sender, System.EventArgs e) {
    if (userName == "fuller.andrew")
        foreach (EditingField field in PrintingSystem.EditingFields)
            field.ReadOnly = true;
}
vb
Imports DevExpress.XtraPrinting
' ...

Private Sub XtraReport1_BeforePrint(sender As Object, e As System.ComponentModel.EventArgs)
    AddHandler PrintingSystem.AfterBuildPages, AddressOf PrintingSystem_AfterBuildPages
End Sub

Private Shared userName As String = System.Environment.UserName

Private Sub PrintingSystem_AfterBuildPages(sender As Object, e As System.EventArgs)
    If userName = "fuller.andrew" Then
        For Each field As EditingField In PrintingSystem.EditingFields
            field.[ReadOnly] = True
        Next
    End If
End Sub

For more information, see Content Editing in Print Preview.

See Also

Edit Content in Print Preview

EditOptions Class

EditOptions Members

DevExpress.XtraReports.UI Namespace