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


The row index used to locate a Row.
The cell name used to locate a Cell.
A System.Windows.Forms.Orientation value that indicates which HeaderCells orientation should be retrieved.
A MultiRowSelectionMode value that indicates the intersection mode of the HeaderCell and the specified Cell.
Retrieves all HeaderCells which intersect with the specified Cell in the Row section.
Syntax
Public Overloads Function GetIntersectedHeaderCells( _
   ByVal rowIndex As Integer, _
   ByVal cellName As String, _
   ByVal direction As Orientation, _
   ByVal mode As MultiRowSelectionMode _
) As HeaderCell()
Dim instance As GcMultiRow
Dim rowIndex As Integer
Dim cellName As String
Dim direction As Orientation
Dim mode As MultiRowSelectionMode
Dim value() As HeaderCell
 
value = instance.GetIntersectedHeaderCells(rowIndex, cellName, direction, mode)
public HeaderCell[] GetIntersectedHeaderCells( 
   int rowIndex,
   string cellName,
   Orientation direction,
   MultiRowSelectionMode mode
)

Parameters

rowIndex
The row index used to locate a Row.
cellName
The cell name used to locate a Cell.
direction
A System.Windows.Forms.Orientation value that indicates which HeaderCells orientation should be retrieved.
mode
A MultiRowSelectionMode value that indicates the intersection 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.ArgumentOutOfRangeExceptionThe rowIndex is less than 0 or greater than RowCount minus 1.
System.ComponentModel.InvalidEnumArgumentException

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

-or-

The mode is not one of the MultiRowSelectionMode values.

System.ArgumentException

The mode is not MultiRowSelectionMode.ContainedCells and MultiRowSelectionMode.IntersectedCells.

-or-

The cellName does not match the name of any Cell in the Row.

Example
The following code example shows how to use this method to retrieve all intersected HeaderCells in the ColumnHeaderSection and Row. This example is part of a larger example available 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.