Beispiel #1
0
        private Cell CreateButtonCell(ICrudGridColumn columnBinding, object entity, string caption, System.Drawing.Image image, Action <object> clickHandler)
        {
            var button = new SourceGrid.Cells.Button(caption)
            {
                Image = image
            };
            var clickHandlerController = new SourceGrid.Cells.Controllers.Button();

            clickHandlerController.Executed += (o, e) => clickHandler(entity);
            button.AddController(clickHandlerController);
            return(button);
        }
Beispiel #2
0
        public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e)
        {
            base.OnValueChanged(sender, e);
            Grid grid1 = (Grid)sender.Grid;

            StrengthTrainingItemDTO entry = null;
            var row = grid1.Rows[sender.Position.Row];

            if (row == null)
            {
                return;
            }
            if (row.Tag == null)
            {
                entry   = new StrengthTrainingItemDTO();
                row.Tag = entry;

                strengthEntry.AddEntry(entry);
                parent.AddEmptyRow(parent.GetSeriesNumber());
            }
            else
            {
                entry = (StrengthTrainingItemDTO)row.Tag;
            }
            Guid newId = (Guid)sender.Value;

            if (newId == Guid.Empty)
            {
                sender.Value = entry.ExerciseId;
                return;
            }
            entry.ExerciseId = newId;
            parent.UpdateCellsReadOnlyMode(row);

            if (!(grid1[row.Index, usrStrengthTrainingSourceGridBase.DeleteRowColumnIndex] is SourceGrid.Cells.Button))
            {
                grid1[row.Index, usrStrengthTrainingSourceGridBase.ExerciseColumnIndex].View.ForeColor = Color.Black;

                if (parent.ReadOnly)
                {
                    return;
                }
                var bnCol1 = new SourceGrid.Cells.Button(null);
                bnCol1.Image       = StrengthTrainingResources.Delete;
                bnCol1.ToolTipText = StrengthTrainingEntryStrings.DeleteThisEntryBtn;
                var ctrButton1 = new SourceGrid.Cells.Controllers.Button();
                ctrButton1.Executed += new EventHandler(deleteRowBtn_Execute);
                bnCol1.View          = new SourceGrid.Cells.Views.Button();
                bnCol1.AddController(ctrButton1);
                grid1[row.Index, usrStrengthTrainingSourceGridBase.DeleteRowColumnIndex] = bnCol1;
            }
        }