// The selected form.gridControlChosenAntibiotics.SetDataSource(vm.Antibiotiks); // Initializing form.gridControlAntibiotics.SetDataSource(antibiotics); // ADDING form.gridViewAntibiotics.RowCellClick += (s, e) => { if (form.Locker.IsLocked) { Mess.boxInf("Формата не е в режим на редакция."); return; } var row = form.gridViewAntibiotics.GetRow(e.RowHandle) as MicroAntibiotik; if (row != null && e.Column == form.col_Choose) { AddAntibiotic(row); } }; // REMOVING form.gridViewChosenAntibiotics.RowCellClick += (s, e) => { if (form.Locker.IsLocked) { Mess.boxInf("Формата не е в режим на редакция."); return; } var row = form.gridViewChosenAntibiotics.GetRow(e.RowHandle) as MicroAntibiotik; if (row != null && e.Column == form.col_Remove) { RemoveAntibiotic(row); } }; // METHODS void AddAntibiotic(MicroAntibiotik antibiotic) { antibiotics.Remove(antibiotic); vm.Antibiotiks.Insert(0, antibiotic); RefreshAntibioticGrids(); } void RemoveAntibiotic(MicroAntibiotik antibiotic) { antibiotics.Add(antibiotic); vm.Antibiotiks.Remove(antibiotic); RefreshAntibioticGrids(); } void RefreshAntibioticGrids() { int topRow = form.gridViewAntibiotics.TopRowIndex; int focusedRowHandle = form.gridViewAntibiotics.FocusedRowHandle; form.gridViewAntibiotics.RefreshData(); form.gridViewAntibiotics.TopRowIndex = topRow; form.gridViewAntibiotics.FocusedRowHandle = focusedRowHandle; topRow = form.gridViewChosenAntibiotics.TopRowIndex; focusedRowHandle = form.gridViewChosenAntibiotics.FocusedRowHandle; form.gridViewChosenAntibiotics.RefreshData(); form.gridViewChosenAntibiotics.TopRowIndex = topRow; form.gridViewChosenAntibiotics.FocusedRowHandle = focusedRowHandle; }