XAF 如何实现ListView单元格批量更改?
public partial class GridViewCellsValueUpdateViewController : ViewController
{
public GridViewCellsValueUpdateViewController()
{
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated()
{
base.OnActivated();
//this.paUpdateCellsValue.Enabled.SetItemValue("ObjectType", SecuritySystem.IsGranted(new ActionAccessPermission(this.paUpdateCellsValue.Id, DevExpress.ExpressApp.Security.ObjectAccessModifier.Allow)));
}
private GridView gridView = null;
private void GridViewCellsValueUpdateViewController_ViewControlsCreated(object sender, EventArgs e)
{
gridView = ((View as ListView).Editor as GridListEditor).GridView;
gridView.OptionsSelection.MultiSelect = true;
gridView.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;
}
private void paUpdateCellsValue_Execute(object sender, ParametrizedActionExecuteEventArgs e)
{
if (e.ParameterCurrentValue == null) return;
gridView.ClearSorting();
DevExpress.XtraGrid.Views.Base.GridCell[] selectedCells = gridView.GetSelectedCells();
object obj = null;
foreach (var item in selectedCells)
{
string typeName = item.Column.ColumnType.Name;
if (typeName == "String" || typeName == "Double" || typeName == "DateTime" || typeName == "Int32")
{
if (item.Column.FieldName == "Create_Date" || item.Column.FieldName == "Write_Date")
{ obj = null; }
else
{obj = e.ParameterCurrentValue; }
}
else
{
obj = ((ObjectSpace)View.ObjectSpace).Session.FindObject(item.Column.ColumnType, new BinaryOperator
("Name", e.ParameterCurrentValue, BinaryOperatorType.Equal));
}
if (obj != null)
{ gridView.SetRowCellValue(item.RowHandle, item.Column, obj); }
obj = null;
}
}
}
{
public GridViewCellsValueUpdateViewController()
{
InitializeComponent();
RegisterActions(components);
}
protected override void OnActivated()
{
base.OnActivated();
//this.paUpdateCellsValue.Enabled.SetItemValue("ObjectType", SecuritySystem.IsGranted(new ActionAccessPermission(this.paUpdateCellsValue.Id, DevExpress.ExpressApp.Security.ObjectAccessModifier.Allow)));
}
private GridView gridView = null;
private void GridViewCellsValueUpdateViewController_ViewControlsCreated(object sender, EventArgs e)
{
gridView = ((View as ListView).Editor as GridListEditor).GridView;
gridView.OptionsSelection.MultiSelect = true;
gridView.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;
}
private void paUpdateCellsValue_Execute(object sender, ParametrizedActionExecuteEventArgs e)
{
if (e.ParameterCurrentValue == null) return;
gridView.ClearSorting();
DevExpress.XtraGrid.Views.Base.GridCell[] selectedCells = gridView.GetSelectedCells();
object obj = null;
foreach (var item in selectedCells)
{
string typeName = item.Column.ColumnType.Name;
if (typeName == "String" || typeName == "Double" || typeName == "DateTime" || typeName == "Int32")
{
if (item.Column.FieldName == "Create_Date" || item.Column.FieldName == "Write_Date")
{ obj = null; }
else
{obj = e.ParameterCurrentValue; }
}
else
{
obj = ((ObjectSpace)View.ObjectSpace).Session.FindObject(item.Column.ColumnType, new BinaryOperator
("Name", e.ParameterCurrentValue, BinaryOperatorType.Equal));
}
if (obj != null)
{ gridView.SetRowCellValue(item.RowHandle, item.Column, obj); }
obj = null;
}
}
}
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/