Articles in this section
Category / Section

How to notify the end users that RichText cells cannot be edited via Formula bar in WPF Spreadsheet?

2 mins read

The current Spreadsheet control does not provide support for editing the RichText cells via the FormulaBar. Hence you can notify the end users through the MessageBox.

When you try to edit the RichText cells via formula bar, a message box is displayed saying it cannot be edited through the FormulaBar.

This can be achieved by handling the PreviewMouseLeftButtonDown event of the FormulaBar. The FormulaBar of Spreadsheet control can be obtained by using the static method GetFieldvalue, Object, of ReflectionHelper class.

C#

spreadSheetControl.WorkBookLoaded += spreadSheetControl_WorkBookLoaded;
void spreadSheetControl_WorkBookLoaded(object sender,WorkbookLoadedEventArgs args)
 {
            var fb = (TextBox)spreadSheetControl.GetFieldValue("FormulaBar");
            fb.PreviewMouseLeftButtonDown += fb_PreviewMouseLeftButtonDown;
  }

C#

void fb_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var grid = this.spreadSheetControl.GridProperties.ActiveSpreadsheetGrid;
    var renderer = grid.CurrentCell.Renderer;
    if (grid != null && renderer != null && renderer.CurrentStyle.CellType == "RichText")
    {
        MessageBox.Show("RichText Cell Cannot be Edited");
        grid.Focus();
        e.Handled = true;
        return;
    }
}

 

 

For your reference, a sample is created with ReflectionHelper class to show the MessageBox while trying to edit FormulaBar.

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/Spreadsheet_demo1266165392.zip  


Conclusion

I hope you enjoyed learning about how to change the visibility of Formula Bar and Headers at runtime in UWP Spreadsheet.


You can refer to our WPF Spreadsheet feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied