Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
Bold w/ FormattedTextEditor in Grid from Bold Button on Ribbon
posted

I'm looking for a way to bold a selected text in my wingrid by clicking a bold button on my ribbon.

For example, I have a wingrid (grid_Questions) setup with a column (IVR_RTF_Text_US) pointing to my formattedTextEditor (txtFormattedForGriduse).  It is setup using this line of code: grid_Questions.DisplayLayout.Bands(0).Columns("IVR_RTF_Text_US").EditorControl = txtFormattedForGriduse

I know how to format selected text in the txtFormattedForGriduse control from the ribbon. I assign this value to the click event of the bold button on the ribbon: txtFormattedForGriduse.EditInfo.PerformAction(FormattedLinkEditorAction.ToggleBold).  This works for formatting the object outside the grid.

However, I also want to do the same thing when I've selected text within a winGrid column, but I can't figure out how to accomplish this.  I know that I can right click my cell in the grid and select bold (and I have this working), but I also want a user to be able to select the text in the cell and click the bold button on the ribbon. Is this possible to do? 

  • 469350
    Verified Answer
    Offline posted

    You can do this using the PerformAction method of the editor in the cell. Note that I am referring to the editor here, which is not the same as the editor control. The code would look something like this:

                UltraGrid grid = this.ActiveControl as UltraGrid;
                if (grid != null)
                {
                    UltraGridCell activeCell = grid.ActiveCell;
                    if (activeCell != null)
                    {
                        FormattedLinkEditor formattedLinkEditor = activeCell.EditorResolved as FormattedLinkEditor;
                        if (formattedLinkEditor != null)
                        {
                            formattedLinkEditor.PerformAction(FormattedLinkEditorAction.ToggleBold, false, false);
                        }                   
                    }
                }