Skip to main content

GridOptionsBehavior.AllowPixelScrolling Property

Gets or sets whether smooth pixel-based vertical scrolling is enabled for rows.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DefaultValue(DefaultBoolean.Default)]
[XtraSerializableProperty]
public virtual DefaultBoolean AllowPixelScrolling { get; set; }

Property Value

Type Default Description
DefaultBoolean Default

A DefaultBoolean value that specifies whether smooth pixel-based vertical scrolling is enabled for rows.

Available values:

Name Description Return Value
True

The value is true.

0

False

The value is false.

1

Default

The value is specified by a global option or a higher-level object.

2

Property Paths

You can access this nested property as listed below:

Object Type Path to AllowPixelScrolling
GridView
.OptionsBehavior .AllowPixelScrolling

Remarks

If the AllowPixelScrolling property is set to Default or False, pixel scrolling is disabled. If this property is set to True, smooth pixel-based vertical scrolling is enabled for rows.

Note

When pixel scrolling is active:

Note

Pixel-based scrolling is not in effect if any of the following features are enabled:

When pixel scrolling is enabled, change the GridView.TopRowPixel property and/or call the GridView.SmoothScroll method to scroll through rows in code.

Pixel Scrolling and Custom Row Heights

Pixel scrolling is affected by the GridView.CalcRowHeight event handler. In the code below, row heights are calculated dynamically. Because of that, pixel scrolling is disabled even though the AllowPixelScrolling is set to True.

public Form1()
{
    InitializeComponent();
    //. . .
    gridView1.OptionsBehavior.AllowPixelScrolling = DevExpress.Utils.DefaultBoolean.True;
}

private void gridView1_CalcRowHeight(object sender, DevExpress.XtraGrid.Views.Grid.RowHeightEventArgs e)
{
    e.RowHeight = MethodThatCalculatesRowHeights();
}

In order to re-enable pixel scrolling, you have to create a GridView descendant that overrides the boolean IsAllowPixelScrollingAutoRowHeight property. Then replace parts of the code that initialize your Views so that these View are instances of this custom class.

public class MyGridView: GridView {
    protected override bool IsAllowPixelScrollingAutoRowHeight {
        get { return true; }
    }
}

//Form1.designer.cs
private void InitializeComponent()
{
    //. . .
    this.gridView1 = new MyGridView();
    //. . .
}
private MyGridView gridView1;

Important

Use pixel scrolling with caution when you calculate row heights dynamically. If you change heights of the same rows throughout the form display, the total client region height changes, and users may be unable to scroll the View up or down to the first (last) record.

To make sure this never happens, use the GridView.CalcRowHeight event to provide custom row height values once, and never change these heights again while the same Form instance exists.

Online Video

DevExpress WinForms: Grid Pixel Scrolling.

See Also