GrapeCity MultiRow Windows Forms Documentation
GetIntersectedHeaderCells(Int32,Int32,Orientation,MultiRowSelectionMode) Method
Example 


The row index used to locate a Row.
The cell index used to locate a Cell.
One of the System.Windows.Forms.Orientation values that indicates which HeaderCells orientation should be retrieved.
Indicates the intersect mode of the HeaderCell and the specified Cell.
Retrieves all the HeaderCells which intersect with the specified Cell in the Row section.
Syntax
<TakeCellFreezeAttribute(True)>
Public Overloads Function GetIntersectedHeaderCells( _
   ByVal rowIndex As Integer, _
   ByVal cellIndex As Integer, _
   ByVal direction As Orientation, _
   ByVal mode As MultiRowSelectionMode _
) As HeaderCell()
Dim instance As GcMultiRow
Dim rowIndex As Integer
Dim cellIndex As Integer
Dim direction As Orientation
Dim mode As MultiRowSelectionMode
Dim value() As HeaderCell
 
value = instance.GetIntersectedHeaderCells(rowIndex, cellIndex, direction, mode)
[TakeCellFreeze(true)]
public HeaderCell[] GetIntersectedHeaderCells( 
   int rowIndex,
   int cellIndex,
   Orientation direction,
   MultiRowSelectionMode mode
)

Parameters

rowIndex
The row index used to locate a Row.
cellIndex
The cell index used to locate a Cell.
direction
One of the System.Windows.Forms.Orientation values that indicates which HeaderCells orientation should be retrieved.
mode
Indicates the intersect mode of the HeaderCell and the specified Cell.

Return Value

A Cell array that represents all the HeaderCells which intersect with the specified Cell in the Row section.
Exceptions
ExceptionDescription
System.ArgumentOutOfRangeException

The rowIndex is less than 0 or greater than RowCount minus 1.

-or-

The cellIndex is less than 0 or greater than the number of Cells in the Row minus 1.

System.ComponentModel.InvalidEnumArgumentException

The direction is not one of the System.Windows.Forms.Orientation values.

-or-

The mode parameter is not one of the MultiRowSelectionMode values.

System.ArgumentExceptionThe mode is not MultiRowSelectionMode.ContainedCells and MultiRowSelectionMode.IntersectedCells.
Example
The following code example shows how to use this method to retrieve all intersected HeaderCells in the ColumnHeaderSection and Row and paints the HeaderCell as needed. This example is part of a larger example for the Office2007Style class.
void gcMultiRow1_CellPainting(object sender, CellPaintingEventArgs e)
        {
            if (!this.gcMultiRow1.CurrentCellPosition.IsEmpty)
            {
                //Retrieve all HeaderCells from ColumnHeaderSection.
                HeaderCell[] verticalHeaderCells = this.gcMultiRow1.GetIntersectedHeaderCells(this.gcMultiRow1.CurrentCellPosition.RowIndex, this.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Vertical, MultiRowSelectionMode.ContainedCells);
                foreach (HeaderCell item in verticalHeaderCells)
                {
                    if (e.SectionIndex == item.RowIndex && e.CellIndex == item.CellIndex && e.Scope == CellScope.ColumnHeader)
                    {
                        using (LinearGradientBrush brush = new LinearGradientBrush(e.CellBounds, Color.Pink, Color.Orange, LinearGradientMode.Vertical))
                        {
                            e.Graphics.FillRectangle(brush, e.CellBounds);
                        }
                        e.PaintForeground(e.ClipBounds);
                        e.CellStyle.Border = new Border(LineStyle.Thin, Color.Orange);
                        e.PaintBorder(e.ClipBounds);
                        e.Handled = true;
                    }
                }
                //Retrieve all HeaderCells from Row section.
                HeaderCell[] horizontalHeaderCells = this.gcMultiRow1.GetIntersectedHeaderCells(this.gcMultiRow1.CurrentCellPosition.RowIndex, this.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Horizontal, MultiRowSelectionMode.ContainedCells);
                foreach (HeaderCell item in horizontalHeaderCells)
                {
                    if (e.SectionIndex == item.RowIndex && e.CellIndex == item.CellIndex && e.Scope == CellScope.Row)
                    {
                        using (LinearGradientBrush brush = new LinearGradientBrush(e.CellBounds, Color.Pink, Color.Orange, LinearGradientMode.Vertical))
                        {
                            e.Graphics.FillRectangle(brush, e.CellBounds);
                        }
                        e.PaintForeground(e.ClipBounds);
                        e.CellStyle.Border = new Border(LineStyle.Thin, Color.Orange);
                        e.PaintBorder(e.ClipBounds);
                        e.Handled = true;
                    }
                }
            }
        }
Private Sub gcMultiRow1_CellPainting(ByVal sender As Object, ByVal e As CellPaintingEventArgs) Handles gcMultiRow1.CellPainting
        If Not Me.gcMultiRow1.CurrentCellPosition.IsEmpty Then
            'Retrieve all HeaderCells from ColumnHeaderSection.
            Dim verticalHeaderCells As HeaderCell() = Me.gcMultiRow1.GetIntersectedHeaderCells(Me.gcMultiRow1.CurrentCellPosition.RowIndex, Me.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Vertical, MultiRowSelectionMode.ContainedCells)
            For Each item As HeaderCell In verticalHeaderCells
                If e.SectionIndex = item.RowIndex AndAlso e.CellIndex = item.CellIndex AndAlso e.Scope = CellScope.ColumnHeader Then
                    Using brush As New LinearGradientBrush(e.CellBounds, Color.Pink, Color.Orange, LinearGradientMode.Vertical)
                        e.Graphics.FillRectangle(brush, e.CellBounds)
                    End Using
                    e.PaintForeground(e.ClipBounds)
                    e.CellStyle.Border = New Border(LineStyle.Thin, Color.Orange)
                    e.PaintBorder(e.ClipBounds)
                    e.Handled = True
                End If
            Next
            'Retrieve all HeaderCells from Row section.
            Dim horizontalHeaderCells As HeaderCell() = Me.gcMultiRow1.GetIntersectedHeaderCells(Me.gcMultiRow1.CurrentCellPosition.RowIndex, Me.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Horizontal, MultiRowSelectionMode.ContainedCells)
            For Each item As HeaderCell In horizontalHeaderCells
                If e.SectionIndex = item.RowIndex AndAlso e.CellIndex = item.CellIndex AndAlso e.Scope = CellScope.Row Then
                    Using brush As New LinearGradientBrush(e.CellBounds, Color.Pink, Color.Orange, LinearGradientMode.Vertical)
                        e.Graphics.FillRectangle(brush, e.CellBounds)
                    End Using
                    e.PaintForeground(e.ClipBounds)
                    e.CellStyle.Border = New Border(LineStyle.Thin, Color.Orange)
                    e.PaintBorder(e.ClipBounds)
                    e.Handled = True
                End If
            Next
        End If
    End Sub
Requirements

Target Platforms: 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

Reference

GcMultiRow Class
GcMultiRow Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.