Version

BeforeColRegionSplit Event

Occurs before a column scrolling region is split into two column scrolling regions.
Syntax
'Declaration
 
Public Event BeforeColRegionSplit As BeforeColRegionSplitEventHandler
public event BeforeColRegionSplitEventHandler BeforeColRegionSplit
Event Data

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

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
NewColScrollRegion The new column scroll region (read-only)
OriginalColScrollRegion The original column scroll region (read-only)
Remarks

Theoriginalcolscrollregionargument 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 split. 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 newcolscrollregion 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 split. You can use this reference to access any of the returned colscrollregion's properties or methods.

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

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

The BeforeColRegionRemoved event is generated before a colscrollregion is removed.

The BeforeColRegionSize event is generated before a colscrollregion is sized.

The BeforeRowRegionSplit event is generated before a rowscrollregion is split.

Example
Following code illustrates how you can use combination of BeforeColRegionSplit and BeforeColRegionSize events to prevent the user from resizing any of the column scroll regions too small.

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

  Private Sub UltraGrid1_BeforeColRegionSplit(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeColRegionSplitEventArgs) Handles ultraGrid1.BeforeColRegionSplit

      ' If the new scroll region is smaller than 100 pixels, then cancel the event
      ' so the UltraGrid doesn't proceed with the region split.
      If e.NewColScrollRegion.Width < 100 Then
          e.Cancel = True

          ' Also cancel if the column scroll region being split would end up being less
          ' than 100 pixels as a result of the split.
      ElseIf e.OriginalColScrollRegion.Width - e.NewColScrollRegion.Width < 100 Then
          e.Cancel = True
      End If

      If e.Cancel Then
          MessageBox.Show("You cannot split a column scroll region smaller than 100 pixels.")
      End If

  End Sub

  Private Sub UltraGrid1_BeforeColRegionSize(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeColRegionSizeEventArgs) Handles ultraGrid1.BeforeColRegionSize

      ' If the user resizes a scroll region in such a way so that any of the
      ' effected scroll regions ends up being less than 100, then cancel it.			
      If e.Region1.Width < 100 Or e.Region2.Width < 100 Then
          e.Cancel = True
          MessageBox.Show("You cannot resize a column scroll region smaller than 100 pixels.")
      End If

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

private void ultraGrid1_BeforeColRegionSplit(object sender, Infragistics.Win.UltraWinGrid.BeforeColRegionSplitEventArgs e)
{
	// If the new scroll region is smaller than 100 pixels, then cancel the event
	// so the UltraGrid doesn't proceed with the region split.
	if ( e.NewColScrollRegion.Width < 100 )
		e.Cancel = true;

	// Also cancel if the column scroll region being split would end up being less
	// than 100 pixels as a result of the split.
	else if ( e.OriginalColScrollRegion.Width - e.NewColScrollRegion.Width < 100 )
		e.Cancel = true;

	if ( e.Cancel )
	{
		MessageBox.Show( "You cannot split a column scroll region smaller than 100 pixels." );
	}
}

private void ultraGrid1_BeforeColRegionSize(object sender, Infragistics.Win.UltraWinGrid.BeforeColRegionSizeEventArgs e)
{
	// If the user resizes a scroll region in such a way so that any of the
	// effected scroll regions ends up being less than 100, then cancel it.			
	if ( e.Region1.Width < 100 || e.Region2.Width < 100 )
	{
		e.Cancel = true;

		MessageBox.Show( "You cannot resize a column scroll region smaller than 100 pixels." );
	}
}
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