Search
Workbook View

The WorkbookView control can be used to display Workbook objects on a Windows form. It displays a single worksheet at a time. The other worksheets in the workbook can be accessed through the tabs at the bottom of the view. New sheets can be added interactively by pressing the 'plus' button. The formula bar displays the data of the currently active cell. The following image illustrates the WorkbookView control:

The WorkbookView displays the cells and objects of the worksheet, provides properties for manipulating the active cell and selection, for scrolling the view, for hiding the scrollbars and the worksheet headers, and so on. More specifically the control provides the users the ability to:

  • scroll the worksheet using the scrollbars, the keyboard or the mouse;
  • modify cell data by pressing F2 while the cell is active, by typing directly, or by using the formula bar;
  • perform auto-fills by dragging the bottom right corner of the current selection;
  • select cells by using the keyboard or by dragging with the mouse;
  • cut, copy and paste cell data;
  • modify interactive objects (such as pictures and charts) by dragging them with the mouse;
  • resize and hide headers, and more.

The workbook is associated with the view through the Workbook property. The currently active worksheet can be get or set through the ActiveWorksheet property. The currently active cell can be get or set through the ActiveCell property. The cell and object selection can be manipulated through the Selection property. The ScrollX and ScrollY properties can be used to get or set the position of the scrollbars. The worksheet headers can be hidden through the ShowHeaders property. The grid lines can be toggled through the ShowGridLines property. The cursors displayed during various user interactions can be customized through a set of properties: PointerCursor, AutoFillCursor, DiagonalResizeCursor, CounterDiagonalResizeCursor, HorizontalResizeCursor, VerticalResizeCursor, MoveCursor, DisallowCursor, HorizontalSplitCursor, and VerticalSplitCursor.

The view provides many events that can be used to track, validate and respond to user activities in the view. Some of the more interesting ones are listed below. For the complete list of events, check WorkbookView Events.

  • CellClicked - raised when the user clicks a cell with the mouse.
  • HyperlinkClicked - raised when the user clicks a cell containing a Hyperlink.
  • InplaceEditStarting - raised when the user is about to in-place edit a cell and can be used to prevent cells from being in-place edited.
  • WorksheetAdded - raised when a new view is added interactively by pressing the 'plus' button.
  • ActiveWorksheetChanged - raised when the user changes the currently displayed worksheet by pressing its respective tab.

The view also provides several methods that can be used to auto-size rows and columns based on the cell content, namely, ResizeColumnToFit, ResizeColumnsToFit, ResizeRowToFit, and ResizeRowsToFit.