private void DelRow()
        {
            // ask user to confirm the deletion
            // TODO:

            // get the next item in the datagrid, if exists
            //_collDataRow.GetEnumerator().

            // delete the last row
            DynDataGridVM.DelRow(DynDataGridVM.SelectedRow);
        }
        /// <summary>
        /// Delete the column, containing the focused cell.
        /// </summary>
        private void DelCol()
        {
            // select the col to delete
            IGridColumn columnToRemove = DynDataGridVM.DynDataGrid.ListColumn.Last();

            if (columnToRemove == null)
            {
                return;
            }

            DynDataGridVM.DelColumn(columnToRemove);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="datagrid"></param>
        public EditComponentDynDataGridVM(ICommonDlg commonDlg, IDynDataGridFactory gridFactory, IDynDataGrid datagrid)
        {
            // connect a callback to know when agrid cell content is modified
            AppCtrlProvider.AppCtrl.DataGrid.GridCellChangedProvider.GridCellChanged = GridCellChanged;

            //AppCtrlProvider.AppCtrl.ActionGridValueModifiedInUI = ActionGridValueModifiedInUI;
            _commonDlg = commonDlg;
            //_gridFactory = gridFactory;

            //_collCell = new GridMappingCell(gridFactory, datagrid);

            //_datagrid = datagrid;

            DynDataGridVM = new DynDataGridVM(gridFactory, datagrid);

            Init();
        }
        /// <summary>
        /// Add a new column at the end of the existing col, create all missing cell on each row.
        /// No need to create cellVM, will be created automatically by the gridMappingcell.
        /// </summary>
        private void AddCol()
        {
            // ask to the user the name and the type
            //List<DlgComboChoiceItem> listItem = new List<DlgComboChoiceItem>();
            //DlgComboChoiceItem selectedBeforeItem = null;

            //var item = new DlgComboChoiceItem("string", "string");
            //listItem.Add(item);
            //selectedBeforeItem = item;
            //item = new DlgComboChoiceItem("int", "int");
            //listItem.Add(item);

            //DlgComboChoiceItem selected;

            string          newColName;
            CommonDlgResult res = _commonDlg.ShowDlgInputText("Input", "Column name:", "col", out newColName);

            if (res != CommonDlgResult.Ok)
            {
                return;
            }

            // check the column name
            if (string.IsNullOrEmpty(newColName))
            {
                return;
            }
            newColName = newColName.Trim();
            if (DynDataGridVM.DynDataGrid.ListColumn.Where(c => c.Name.Equals(newColName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault() != null)
            {
                _commonDlg.ShowError("The name is already used by a column.");
                return;
            }

            // create a column, type string
            IGridColumnVM gridColumnVM;

            DynDataGridVM.CreateColumnWithCells(GridColumnType.String, newColName, out gridColumnVM);
        }
        private void AddRow()
        {
            //---test solution A
            // create a row with empty cells, at the end.
            //IGridRow row = DynDataGridVM.CreateRowWithCells();

            //---test solution B
            IGridRow gridRow = new GridRow(DynDataGridVM.DynDataGrid);

            // add the row to the dataGrid
            DynDataGridVM.DynDataGrid.AddRow(gridRow);

            // create cells corresponding to the columns
            foreach (IGridColumn col in DynDataGridVM.DynDataGrid.ListColumn)
            {
                // create the cell, matching the type defined in the column
                IGridCell cell = DynDataGridVM.Factory.CreateCell(DynDataGridVM.DynDataGrid, col, gridRow);
                gridRow.AddCell(cell);
            }

            // add the dataGrid row to the VM
            DynDataGridVM.AddRow(gridRow);
        }