Version

BeforeColRegionScroll Event

Occurs before a column scrolling region is scrolled.
Syntax
'Declaration
 
Public Event BeforeColRegionScroll As BeforeColRegionScrollEventHandler
public event BeforeColRegionScrollEventHandler BeforeColRegionScroll
Event Data

The event handler receives an argument of type BeforeColRegionScrollEventArgs containing data related to this event. The following BeforeColRegionScrollEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
NewState The new state column scroll region (read-only)
OldState The old state column scroll region (read-only)
Remarks

The newstate argument returns a reference to a ColScrollRegion object that can be used to set properties of, and invoke methods on, the colscrollregion as it exists before the scroll. You can use this reference to access any of the returned colscrollregion's properties or methods.

The oldstate argument returns a reference to a ColScrollRegion object that can be used to set properties of, and invoke methods on, the colscrollregion as it will exist after the scroll. You can use this reference to access any of the returned colscrollregion's properties or methods. However, the Position and Width properties of this colscrollregion are read-only in this event procedure.

The cancel argument enables you to programmatically prevent the colscrollregion from scrolling. This argument can be used to prevent the user from scrolling unless a certain condition is met.

This event is generated before a colscrollregion is scrolled, either programmatically, or by user interaction. A colscrollregion can be scrolled programmatically by invoking its Scroll method.

The ScrollBar property of a scrolling region determines whether a scroll bar is displayed for that scrolling region.

The AfterColRegionScroll event, which occurs after a colscrollregion was scrolled, is generated after this event, provided cancel is not set to True.

The BeforeRowRegionScroll event is generated before a rowscrollregion is scrolled.

Example
Following code prevents columns from scrolling by canceling BeforeColRegionScroll event.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Diagnostics

   Private Sub UltraGrid1_BeforeColRegionScroll(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeColRegionScrollEventArgs) Handles ultraGrid1.BeforeColRegionScroll

       ' There may be circumstances where you may want to conditionally prevent the user
       ' from scrolling. To accomplish that, you can hook into the BeforeColRegionScroll 
       ' event and cancel it when it gets fired.

       If Me.chkLockScrolling.Checked Then e.Cancel = True

       ' Write old and the new positions of the scroll bar.
       Debug.WriteLine("Old position of the scroll bar is " & e.OldState.Position)
       Debug.WriteLine("New position of the scroll bar is " & e.NewState.Position)

   End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_BeforeColRegionScroll(object sender, Infragistics.Win.UltraWinGrid.BeforeColRegionScrollEventArgs e)
{

	// There may be circumstances where you may want to conditionally prevent the user
	// from scrolling. To accomplish that, you can hook into the BeforeColRegionScroll 
	// event and cancel it when it gets fired.

	if ( this.chkLockScrolling.Checked )
		e.Cancel = true;

	// Write old and the new positions of the scroll bar.
	Debug.WriteLine( "Old position of the scroll bar is " + e.OldState.Position );
	Debug.WriteLine( "New position of the scroll bar is " + e.NewState.Position );

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also