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
235
How can I block add Worksheets?
posted

Hi

We need just two worksheet. "Setpoints", "Values"

But when click add button... worksheet added...

how can we block this button? or collapse

thank you

  • 1935
    Verified Answer
    posted

    Hello Joseph,

    Regarding to what you wish to achieve, two new properties will be available in the upcoming service release for 15.2 and 16.1 versions of the Infragistics WPF product that will determine the allowing of adding, inserting and removing worksheets - AllowAddWorksheet and AllowDeleteWorksheet. Setting these properties to false will hide all the visual elements related to the functionality for adding and removing of worksheets.

    You could find information about the scheduled date for the upcoming service release in our website - http://es.infragistics.com/support/service-releases

    Till then, what you could do is to protect the workbook that will prevent the user from adding, inserting and removing worksheets.

    That's a snippet code for protecting the workbook in the XamSpreadsheet's Loaded event handler:

    private void spreadsheet_Loaded(object sender, RoutedEventArgs e)
    {
        var spreadsheet = sender as XamSpreadsheet;
        spreadsheet.Workbook.Protect();           
    }

    Please keep in mind that the button for adding a worksheet will be disabled, as well as all the other visual elements like the menu items for inserting and deleting worksheets. If you wish to collapse that button, you could get it by using the Infragistics Utilities class and setting its Visibility to collapse.

    private void spreadsheet_Loaded(object sender, RoutedEventArgs e)
            {
                SpreadsheetTabItemArea tabItemArea =
                    Utilities.GetDescendantFromType(sender as DependencyObject, typeof(SpreadsheetTabItemArea), false) as SpreadsheetTabItemArea;
                if (tabItemArea != null)
                {
                    Button addSheet = Utilities.GetDescendantFromName(tabItemArea, "AddSheet") as Button;
                    if (addSheet != null)
                    {
                        addSheet.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
            }

    Please let me know if you have any other questions on this matter.