コード例 #1
0
        void SetSelectionStyle(string propName, object value)
        {
            // get the property we're about to change
            var pi = typeof(CellStyle).GetProperty(propName);

            // create undo action
            var action = new CellStyleChangeAction(_flex);

            // apply the change to the current selection
            foreach (var rng in _flex.Selection.Cells)
            {
                // get cell style
                var row = _flex.Rows[rng.Row] as ExcelRow;
                var col = _flex.Columns[rng.Column];
                var cs  = row.GetCellStyle(col);

                // clone it/create a new one
                cs = cs == null
                    ? new ExcelCellStyle()
                    : (ExcelCellStyle)cs.Clone();

                // apply the new setting
                pi.SetValue(cs, value, null);
                row.SetCellStyle(col, cs);
            }

            // save undo action
            action.SaveNewState();
            _flex.UndoStack.AddAction(action);
        }
コード例 #2
0
        void SetSelectionStyle(string propName, object value)
        {
            // get the property we're about to change
            var pi = typeof(CellStyle).GetProperty(propName);

            // create undo action
            var action = new CellStyleChangeAction(_flex);

            // apply the change to the current selection
            foreach (var rng in _flex.Selection.Cells)
            {
                // get cell style
                var row = _flex.Rows[rng.Row] as ExcelRow;
                var col = _flex.Columns[rng.Column];
                var cs = row.GetCellStyle(col);

                // clone it/create a new one
                cs = cs == null
                    ? new ExcelCellStyle()
                    : (ExcelCellStyle)cs.Clone();

                // apply the new setting
                pi.SetValue(cs, value, null);
                row.SetCellStyle(col, cs);
            }

            // save undo action
            action.SaveNewState();
            _flex.UndoStack.AddAction(action);
        }