Skip to main content
A newer version of this page is available. .

XPView.Criteria Property

Gets or sets the criteria associated with the view.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v18.2.dll

Declaration

[TypeConverter("DevExpress.Xpo.Design.CriteriaConverter, DevExpress.Xpo.v18.2.Design, Version=18.2.99.0, Culture=neutral, PublicKeyToken=c38a27d2243c2672")]
[DefaultValue(null)]
public CriteriaOperator Criteria { get; set; }

Property Value

Type Default Description
CriteriaOperator *null*

A CriteriaOperator descendant which represents the criteria associated with the view.

Remarks

Use the Criteria property to change the criteria by which the persistent objects will be filtered while the view is being loaded. Changing this property immediately refreshes the view.

Example

The following sample code demonstrates how to display persons who are older than 30. Only those persistent objects whose Age property’s value is greater than 30 are retrieved.

The image below shows the result.

XPView_Criteria

using DevExpress.Xpo;
using DevExpress.Data.Filtering;
// ...
class SampleTable : XPBaseObject {
    private int id;
    private string name;
    private int age;

    SampleTable(Session session) : base(session) {
        this.name = "John";
        this.age = 25;
    }

    [Key(true)]
    public int ID {
        get { return id; }
        set { SetPropertyValue<int>("ID", id, value); }
    }

    public string Name {
        get { return name; }
        set { SetPropertyValue<string>("Name", name, value); }
    }

    public int Age {
        get { return age; }
        set { SetPropertyValue<int>("Age", age, value); }
    }
}

// ...

xpView1.Criteria = CriteriaOperator.Parse("Age > 30", null);

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Criteria property.

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.

See Also