Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Restrict the Number of Visible Rows and Columns in a Worksheet

This example demonstrates how to use the WorksheetDisplayArea.SetSize method to restrict the number of rows and columns the SpreadsheetControl displays in a worksheet.

The code snippet below shows how to set the active worksheet’s visible area to the used range the Worksheet.GetUsedRange method returns.

SpreadsheetControl_WorksheetDisplayArea

// Access the active worksheet.
Worksheet worksheet = spreadsheetControl.ActiveWorksheet;
// Get the range containing non-empty cells.
CellRange usedRange = worksheet.GetUsedRange();
// Restrict the worksheet's visible area to the used range.
spreadsheetControl.WorksheetDisplayArea.SetSize(worksheet.Index, usedRange.ColumnCount, usedRange.RowCount);

#Change the SpreadsheetControl’s Background Color

Use the SpreadsheetViewOptions.BackColor property to change the color of the SpreadsheetControl’s non-editable area.

SpreadsheetControl_WorksheetDisplayArea_Custom_BackColor

spreadsheetControl.Options.View.BackColor = Color.FromArgb(0xef, 0xf6, 0xf3);