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?
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); } } }
Mike, thanks for the help. I was able to take this and make it work for my purposes.