/// <summary> /// create a column in the dataGird model and also in the corresponding VM, depending on the type. /// (the UI wil be updated automatically). /// Create all empty cells (model and view model). /// </summary> /// <param name="typeCol"></param> /// <param name="newColName"></param> /// <param name="colObj"></param> /// <param name="gridColumnVM"></param> /// <returns></returns> public DynDataGridErrCode CreateColumnWithCells(GridColumnType typeCol, string newColName, object colObj, out IGridColumnVM gridColumnVM) { gridColumnVM = null; // create the col in the data model, depending on the type IGridColumn column; DynDataGridErrCode errCode = _gridFactory.CreateColumn(_dynDataGrid, typeCol, newColName, colObj, out column); if (errCode != DynDataGridErrCode.Ok) { return(errCode); } // create a empty cell for each row in the dataGrid model foreach (IGridRow gridRow in _dynDataGrid.ListRow) { // depending on the type of the new column IGridCell cell = _gridFactory.CreateCell(_dynDataGrid, column, gridRow); gridRow.AddCell(cell); } // update the UI, add the colVM gridColumnVM = AddColumnVM(column); RaisePropertyChanged("CollColumnGrid"); return(DynDataGridErrCode.Ok); }
/// <summary> /// create the col in the data model, depending on the type. /// Provide an object to attach to the column. /// </summary> /// <param name="typeCol"></param> /// <param name="newColName"></param> /// <returns></returns> public DynDataGridErrCode CreateColumn(IDynDataGrid dataGrid, GridColumnType typeCol, string newColName, object colObj, out IGridColumn column) { column = null; // check the name DynDataGridErrCode errCode = CheckColumnName(dataGrid, newColName); if (errCode != DynDataGridErrCode.Ok) { return(errCode); } column = CreateColumn(typeCol, newColName, colObj); dataGrid.AddColumn(column); return(DynDataGridErrCode.Ok); }