.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理

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 == nullreturn;
            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;
            }
        }
    }

 

posted on 2011-03-15 17:23  Tonyyang  阅读(640)  评论(0编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/