private void CreateDataGrid(IDynDataGridFactory dynDataGridFactory) { DataGrid = new DynDataGrid(); //----create columns IGridColumn columnKey; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.String, "Key", out columnKey); // this column cells are read-only columnKey.IsEditionReadOnly = true; IGridColumn columnValue; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.String, "Value", out columnValue); // col checkbox IGridColumn columnCheck; dynDataGridFactory.CreateColumn(DataGrid, GridColumnType.CheckBox, "Checked", out columnCheck); //----create a data row, with empty cells IGridRow row = DynDataGridFactory.CreateRowWithCells(DataGrid); //----create data cells DataGrid.SetCellValue(row, columnKey, "keyYes"); DataGrid.SetCellValue(row, "Value", "Oui"); // checked by default DataGrid.SetCellValue(row, "Checked", true); // test: search a column by the name //IGridColumn colFound = DataGrid.FindColumnByName("Key"); }
/// <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); }
private void CreateDataGrid2(IDynDataGridFactory dynDataGridFactory) { DataGrid2 = new DynDataGrid(); //----create columns IGridColumn columnId; dynDataGridFactory.CreateColumn(DataGrid2, GridColumnType.String, "Id", out columnId); // this column cells are read-only columnId.IsEditionReadOnly = true; //----create a data row, with empty cells //IGridRow row = dynDataGridFactory.CreateRowWithCells(DataGrid2); //----create data cells //DataGrid2.SetCellValue(row, columnId, "Id"); }