The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
V19.1
19.2 (EAP/Beta)
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Access the Spreadsheet Control

  • 2 min to read

This topic describes how to access and customize the SpreadsheetControl object in WinForms applications that use the Office Module. The steps below demonstrate how to restrict the number of visible rows and columns in a worksheet.

  1. Create a custom ViewController in the WinForms module project.
  2. In the overridden OnActivated method, get the SpreadsheetServiceController and subscribe to its CustomizeSpreadsheetControl event.
  3. In the CustomizeSpreadsheetControl's handler, use the SetSize to specify the number of visible rows and columns for an active worksheet.

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Office.Win;
    using DevExpress.Spreadsheet;
    using DevExpress.XtraSpreadsheet;
    // ...
    public class CustomSpreadsheetController : ViewController {
        protected override void OnActivated() {
            base.OnActivated();
            SpreadsheetServiceController controller = Frame.GetController<SpreadsheetServiceController>();
            if(controller != null) {
                controller.CustomizeSpreadsheetControl += Controller_CustomizeSpreadsheetControl;
            }
        }
        private void Controller_CustomizeSpreadsheetControl(object sender, CustomizeSpreadsheetEventArgs e) {
            SpreadsheetControl spreadsheetControl = ((SpreadsheetPropertyEditor)sender).SpreadsheetControl;
            Worksheet worksheet = spreadsheetControl.ActiveWorksheet;
            spreadsheetControl.WorksheetDisplayArea.SetSize(worksheet.Index, 5, 10);
        }
    }