View.Refresh(Boolean) Method
Refreshes displayed values of the View‘s controls with new values from the data source collection (and optionally, from the database itself).
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Parameters
Name | Type | Description |
---|---|---|
refreshDataSource | Boolean | true, if the data source needs to be refreshed as well; otherwise, false. |
Remarks
Use this method to manually refresh control values in the current View when displayed objects do not raise notifications on data changes themselves (e.g., when the object type does not support INotifyPropertyChanged, or when the data source does not support IBindingList).
The Refresh method calls View.RefreshDataSource when the refreshDataSource parameter is set to true.
The following example uses a Parametrized Action to search for a Person by LastName, and then assigns all deferred tasks to that person.
using System.Collections.Generic;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.Persistent.BaseImpl;
using MainDemo.Module.BusinessObjects;
// ...
public class AssignTasksController : ViewController {
public AssignTasksController() {
TargetObjectType = typeof(DemoTask);
ParametrizedAction assignTasksAction = new ParametrizedAction(
this, "AssignTasks", PredefinedCategory.Edit, typeof(string));
assignTasksAction.Execute += AssignTasksAction_Execute;
}
private void AssignTasksAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) {
using(IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Person))) {
string personParamValue = e.ParameterCurrentValue as string;
Person person = objectSpace.FirstOrDefault<Person>(p => p.LastName.Contains(personParamValue));
if(person != null) {
CriteriaOperator taskCriteria = CriteriaOperator.Parse("[Status] = ?", TaskStatus.Deferred);
IList<DemoTask> tasks = objectSpace.GetObjects<DemoTask>(taskCriteria);
foreach(DemoTask task in tasks) {
task.AssignedTo = person;
}
objectSpace.CommitChanges();
}
}
View.Refresh(true);
}
}