PowerTools MultiRow for Windows Forms 8.0J
GetIntersectedHeaderCells(Int32,String,Orientation,MultiRowSelectionMode) メソッド
使用例 

Rowを指定する行インデックス。
Cellを指定するセル名。
HeaderCellを取得する方向を示すSystem.Windows.Forms.Orientation値の1つ。
HeaderCellと指定したCellの交差モードを示すMultiRowSelectionMode値の1つ。
Rowセクション内の指定したCellと交差するすべてのHeaderCellを取得します。
構文
Public Overloads Function GetIntersectedHeaderCells( _
   ByVal rowIndex As Integer, _
   ByVal cellName As String, _
   ByVal direction As Orientation, _
   ByVal mode As MultiRowSelectionMode _
) As HeaderCell()

パラメータ

rowIndex
Rowを指定する行インデックス。
cellName
Cellを指定するセル名。
direction
HeaderCellを取得する方向を示すSystem.Windows.Forms.Orientation値の1つ。
mode
HeaderCellと指定したCellの交差モードを示すMultiRowSelectionMode値の1つ。

戻り値の型

Rowセクション内の指定したCellと交差するすべてのHeaderCellを表すCellの配列。
例外
例外解説
System.ArgumentOutOfRangeExceptionrowIndex0未満か、RowCount - 1を超えています。
System.ComponentModel.InvalidEnumArgumentException

directionSystem.Windows.Forms.Orientation値の1つではありません。

または

modeMultiRowSelectionMode値の1つではありません。

System.ArgumentException

modeMultiRowSelectionMode.ContainedCellsMultiRowSelectionMode.IntersectedCellsのどちらでもありません。

または

cellNameRow内のどのCellの名前とも一致しません。

使用例
次のサンプルコードは、このメソッドを使用してColumnHeaderSectionおよびRow内の交差するすべてのHeaderCellを取得し、これらのHeaderCellをアプリケーションの要件に合わせて描画する方法を示します。このサンプルコードは、Office2007Styleに示されている詳細なコード例の一部を抜粋したものです。
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
参照

GcMultiRow クラス
GcMultiRow メンバ
オーバーロード一覧

 

 


© 2008-2015 GrapeCity inc. All rights reserved.