コード例 #1
0
        public static void SpreadsheetControl_PopupMenuShowing(object sender, DevExpress.XtraSpreadsheet.PopupMenuShowingEventArgs e)
        {
            if (sender is not SpreadsheetControl spreadsheetControl)
            {
                return;
            }

            if (e.MenuType == DevExpress.XtraSpreadsheet.SpreadsheetMenuType.Cell)
            {
                Cell activeCell = spreadsheetControl.ActiveCell;
                if (activeCell.Value.IsEmpty || (!activeCell.HasFormula && activeCell.Value.IsText))
                {
                    var setRichTextItem = new SpreadsheetMenuItem("Set rich text ...",
                                                                  (s, args) =>
                    {
                        if (spreadsheetControl?.IsDisposed ?? true)
                        {
                            return;
                        }

                        using var richEditForm = new SpreadRichTextEditForm(spreadsheetControl.ActiveCell);
                        richEditForm.ShowDialog();
                    })
                    {
                        BeginGroup = true
                    };
                    setRichTextItem.ImageOptions.SvgImage     = (DevExpress.Utils.Svg.SvgImage)Properties.Resources.List;
                    setRichTextItem.ImageOptions.SvgImageSize = new Size(16, 16);

                    e.Menu.Items.Add(setRichTextItem);
                }
            }
        }
    }
コード例 #2
0
 public static void SpreadsheetControl_CellBeginEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCellCancelEventArgs e)
 {
     if (e.Cell.HasRichText)
     {
         e.Cancel = true;
         using var richEditForm = new SpreadRichTextEditForm(e.Cell);
         richEditForm.ShowDialog();
     }
 }