PowerTools MultiRow for Windows Forms 8.0J
Office2007Style 列挙体
使用例 使用例 

Office 2007の配色パターンのような外観を指定します。
構文
Public Enum Office2007Style 
   Inherits System.Enum
public enum Office2007Style : System.Enum 
メンバ
メンバ解説
BlackOffice 2007の配色パターン「黒」のような外観を表します。
BlueOffice 2007の配色パターン「青」のような外観を表します。
NoneOffice 2007の外観を使用しません。
SilverOffice 2007の配色パターン「銀色」のような外観を表します。
解説
GcMultiRowコントロールでは、ヘッダセル、スクロールバー、分割ボタンの3つの視覚要素をOffice 2007スタイルで描画できます。これらの要素をカスタマイズするには、それぞれHeaderCell.Office2007Styleプロパティ、GcMultiRow.ScrollBarOffice2007Styleプロパティ、およびGcMultiRow.SplitOffice2007Styleプロパティを設定します。
使用例
次のサンプルコードは、GcMultiRowのOffice2007Styleに関連する要素を使用して、Excel2007の外観を示すデモを作成します。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace GrapeCity.Win.MultiRow.SampleCode
{
    class Office2007StyleDemo : Form
    {
        private GcMultiRow gcMultiRow1 = new GcMultiRow();
        private FlowLayoutPanel panel = new FlowLayoutPanel();

        public Office2007StyleDemo()
        {
            this.Text = "Office2007Style Demo";
            this.Size = new Size(550, 350);

            // Initial flow layout panel and add to form.
            this.panel.Dock = DockStyle.Left;
            this.panel.Size = new Size(200, 200);
            this.panel.FlowDirection = FlowDirection.TopDown;
            this.panel.WrapContents = false;
            this.panel.Padding = new Padding(5);
            this.panel.AutoSize = true;
            this.Controls.Add(panel);

            // Add MultiRow to form
            this.gcMultiRow1.Dock = DockStyle.Left;
            this.gcMultiRow1.Width = 400;
            this.Controls.Add(this.gcMultiRow1);

            this.Load += new EventHandler(Form1_Load);

            InitButton();

            this.StartPosition = FormStartPosition.CenterScreen;

            //Add split line to GcMultiRow.
            this.gcMultiRow1.AddViewport(0, -1);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            gcMultiRow1.Template = Template.CreateGridTemplate(5);
            gcMultiRow1.RowCount = 20;
            gcMultiRow1.ShowEditingIcon = false;
            gcMultiRow1.CellEnter += new EventHandler<CellEventArgs>(gcMultiRow1_CellEnter);
            gcMultiRow1.CellLeave += new EventHandler<CellEventArgs>(gcMultiRow1_CellLeave);
            gcMultiRow1.CellPainting += new EventHandler<CellPaintingEventArgs>(gcMultiRow1_CellPainting);
        }
        
        #region Button Event Handlers
        void setBlueStyle_Click(object sender, EventArgs e)
        {
            Template template1 = this.gcMultiRow1.Template;
            //Set ScrollBar to Office 2007 style.
            this.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Blue;
            //Set Split line to Office 2007 style.
            this.gcMultiRow1.SplitOffice2007Style = Office2007Style.Blue;
            //Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
            CellStyle borderStyle = new CellStyle();
            borderStyle.Border = new Border(LineStyle.Thin, Color.FromArgb(255, 156, 182, 206));
            this.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle;
            this.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle;

            //Set all HeaderCell to Office2007Style.
            foreach (Cell cell1 in template1.ColumnHeaders[0].Cells)
            {
                HeaderCell headerCell1 = cell1 as HeaderCell;
                if (headerCell1 != null)
                {
                    headerCell1.Office2007Style = Office2007Style.Blue;
                }
            }
            HeaderCell rowHeaderCell1 = template1.Row.Cells[template1.Row.Cells.Count - 1] as HeaderCell;
            if (rowHeaderCell1 != null)
            {
                rowHeaderCell1.Office2007Style = Office2007Style.Blue;
            }

            this.gcMultiRow1.Template = template1;
        }

        void setSilverStyle_Click(object sender, EventArgs e)
        {
            Template template1 = this.gcMultiRow1.Template;
            //Set ScrollBar to Office 2007 style.
            this.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Silver;
            //Set Split line to Office 2007 style.
            this.gcMultiRow1.SplitOffice2007Style = Office2007Style.Silver;
            //Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
            CellStyle borderStyle = new CellStyle();
            borderStyle.Border = new Border(LineStyle.Thin, Color.FromArgb(255, 148, 146, 148));
            this.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle;
            this.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle;

            //Set all HeaderCell to Office2007Style.
            foreach (Cell cell1 in template1.ColumnHeaders[0].Cells)
            {
                HeaderCell headerCell1 = cell1 as HeaderCell;
                if (headerCell1 != null)
                {
                    headerCell1.Office2007Style = Office2007Style.Silver;
                }
            }
            HeaderCell rowHeaderCell1 = template1.Row.Cells[template1.Row.Cells.Count - 1] as HeaderCell;
            if (rowHeaderCell1 != null)
            {
                rowHeaderCell1.Office2007Style = Office2007Style.Silver;
            }

            this.gcMultiRow1.Template = template1;
        }

        void setBlackStyle_Click(object sender, EventArgs e)
        {
            Template template1 = this.gcMultiRow1.Template;
            //Set ScrollBar to Office 2007 style.
            this.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Black;
            //Set Split line to Office 2007 style.
            this.gcMultiRow1.SplitOffice2007Style = Office2007Style.Black;
            //Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
            CellStyle borderStyle = new CellStyle();
            borderStyle.Border = new Border(LineStyle.Thin, Color.FromArgb(255, 181, 182, 181));
            this.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle;
            this.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle;

            //Set all HeaderCell to Office2007Style.
            foreach (Cell cell1 in template1.ColumnHeaders[0].Cells)
            {
                HeaderCell headerCell1 = cell1 as HeaderCell;
                if (headerCell1 != null)
                {
                    headerCell1.Office2007Style = Office2007Style.Black;
                }
            }
            HeaderCell rowHeaderCell1 = template1.Row.Cells[template1.Row.Cells.Count - 1] as HeaderCell;
            if (rowHeaderCell1 != null)
            {
                rowHeaderCell1.Office2007Style = Office2007Style.Black;
            }

            this.gcMultiRow1.Template = template1;
        }

        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;
                    }
                }
            }
        }
        #endregion

        void gcMultiRow1_CellLeave(object sender, CellEventArgs e)
        {
            InvalidateIntersectHeaderCells();
        }

        void gcMultiRow1_CellEnter(object sender, CellEventArgs e)
        {
            InvalidateIntersectHeaderCells();
        }

        private void InvalidateIntersectHeaderCells()
        {
            HeaderCell[] verticalHeaderCells = this.gcMultiRow1.GetIntersectedHeaderCells(this.gcMultiRow1.CurrentCellPosition.RowIndex, this.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Vertical, MultiRowSelectionMode.ContainedCells);
            foreach (HeaderCell item in verticalHeaderCells)
            {
                item.Invalidate();
            }
            HeaderCell[] horizontalHeaderCells = this.gcMultiRow1.GetIntersectedHeaderCells(this.gcMultiRow1.CurrentCellPosition.RowIndex, this.gcMultiRow1.CurrentCellPosition.CellIndex, Orientation.Horizontal, MultiRowSelectionMode.ContainedCells);
            foreach (HeaderCell item in horizontalHeaderCells)
            {
                item.Invalidate();
            }
        }

        #region Initialize Buttons

        private void InitButton()
        {
            AddButton(setBlueStyle, "Set Blue Office style", new EventHandler(setBlueStyle_Click));
            AddButton(setSilverStyle, "Set Silver Office style", new EventHandler(setSilverStyle_Click));
            AddButton(setBlackStyle, "Set Black Office style", new EventHandler(setBlackStyle_Click));
        }

        private void AddButton(Button button, string text, EventHandler eventHandler)
        {
            this.panel.Controls.Add(button);
            button.Text = text;
            button.AutoSize = true;
            button.Click += eventHandler;
        }

        Button setBlueStyle = new Button();
        Button setSilverStyle = new Button();
        Button setBlackStyle = new Button();

        #endregion

        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Office2007StyleDemo());
        }
    }
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports GrapeCity.Win.MultiRow

Class Office2007StyleDemo
    Inherits Form
    Friend WithEvents gcMultiRow1 As New GcMultiRow()
    Private panel As New FlowLayoutPanel()

    Public Sub New()
        Me.Text = "Office2007Style Demo"
        Me.Size = New Size(550, 350)

        ' Initial flow layout panel and add to form.
        Me.panel.Dock = DockStyle.Left
        Me.panel.Size = New Size(200, 200)
        Me.panel.FlowDirection = FlowDirection.TopDown
        Me.panel.WrapContents = False
        Me.panel.Padding = New Padding(5)
        Me.panel.AutoSize = True
        Me.Controls.Add(panel)

        ' Add MultiRow to form
        Me.gcMultiRow1.Dock = DockStyle.Left
        Me.gcMultiRow1.Width = 400
        Me.Controls.Add(Me.gcMultiRow1)

        InitButton()

        Me.StartPosition = FormStartPosition.CenterScreen
        'Add split line to GcMultiRow.
        Me.gcMultiRow1.AddViewport(0, -1)
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        gcMultiRow1.Template = Template.CreateGridTemplate(5)
        gcMultiRow1.RowCount = 20
        gcMultiRow1.ShowEditingIcon = False
    End Sub

#Region "Button Event Handlers"
    Private Sub setBlueStyle_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setBlueStyle.Click
        Dim template1 As Template = Me.gcMultiRow1.Template
        'Set ScrollBar to Office 2007 style.
        Me.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Blue
        'Set Split line to Office 2007 style.
        Me.gcMultiRow1.SplitOffice2007Style = Office2007Style.Blue
        'Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
        Dim borderStyle As New CellStyle()
        borderStyle.Border = New Border(LineStyle.Thin, Color.FromArgb(255, 156, 182, 206))
        Me.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle
        Me.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle

        'Set all HeaderCell to Office2007Style.
        For Each cell1 As Cell In template1.ColumnHeaders(0).Cells
            Dim headerCell1 As HeaderCell = TryCast(cell1, HeaderCell)
            If Not headerCell1 Is Nothing Then
                headerCell1.Office2007Style = Office2007Style.Blue
            End If
        Next
        Dim rowHeaderCell1 As HeaderCell = TryCast(template1.Row.Cells(template1.Row.Cells.Count - 1), HeaderCell)
        If Not rowHeaderCell1 Is Nothing Then
            rowHeaderCell1.Office2007Style = Office2007Style.Blue
        End If

        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setSilverStyle_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setSilverStyle.Click
        Dim template1 As Template = Me.gcMultiRow1.Template
        'Set ScrollBar to Office 2007 style.
        Me.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Silver
        'Set Split line to Office 2007 style.
        Me.gcMultiRow1.SplitOffice2007Style = Office2007Style.Silver
        'Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
        Dim borderStyle As New CellStyle()
        borderStyle.Border = New Border(LineStyle.Thin, Color.FromArgb(255, 148, 146, 148))
        Me.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle
        Me.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle

        'Set all HeaderCell to Office2007Style.
        For Each cell1 As Cell In template1.ColumnHeaders(0).Cells
            Dim headerCell1 As HeaderCell = TryCast(cell1, HeaderCell)
            If Not headerCell1 Is Nothing Then
                headerCell1.Office2007Style = Office2007Style.Silver
            End If
        Next
        Dim rowHeaderCell1 As HeaderCell = TryCast(template1.Row.Cells(template1.Row.Cells.Count - 1), HeaderCell)
        If Not rowHeaderCell1 Is Nothing Then
            rowHeaderCell1.Office2007Style = Office2007Style.Silver
        End If

        Me.gcMultiRow1.Template = template1
    End Sub

    Private Sub setBlackStyle_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setBlackStyle.Click
        Dim template1 As Template = Me.gcMultiRow1.Template
        'Set ScrollBar to Office 2007 style.
        Me.gcMultiRow1.ScrollBarOffice2007Style = Office2007Style.Black
        'Set Split line to Office 2007 style.
        Me.gcMultiRow1.SplitOffice2007Style = Office2007Style.Black
        'Set All HeaderCell's border to Office 2007 Style. you can chang the border to any style.
        Dim borderStyle As New CellStyle()
        borderStyle.Border = New Border(LineStyle.Thin, Color.FromArgb(255, 181, 182, 181))
        Me.gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle = borderStyle
        Me.gcMultiRow1.RowsDefaultHeaderCellStyle = borderStyle

        'Set all HeaderCell to Office2007Style.
        For Each cell1 As Cell In template1.ColumnHeaders(0).Cells
            Dim headerCell1 As HeaderCell = TryCast(cell1, HeaderCell)
            If Not headerCell1 Is Nothing Then
                headerCell1.Office2007Style = Office2007Style.Black
            End If
        Next
        Dim rowHeaderCell1 As HeaderCell = TryCast(template1.Row.Cells(template1.Row.Cells.Count - 1), HeaderCell)
        If Not rowHeaderCell1 Is Nothing Then
            rowHeaderCell1.Office2007Style = Office2007Style.Black
        End If

        Me.gcMultiRow1.Template = template1
    End Sub

    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
#End Region

    Private Sub gcMultiRow1_CellLeave(ByVal sender As Object, ByVal e As CellEventArgs) Handles gcMultiRow1.CellLeave
        InvalidateIntersectHeaderCells()
    End Sub

    Private Sub gcMultiRow1_CellEnter(ByVal sender As Object, ByVal e As CellEventArgs) Handles gcMultiRow1.CellEnter
        InvalidateIntersectHeaderCells()
    End Sub

    Private Sub InvalidateIntersectHeaderCells()
        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
            item.Invalidate()
        Next
        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
            item.Invalidate()
        Next
    End Sub

#Region "Initialize Buttons"

    Private Sub InitButton()
        AddButton(setBlueStyle, "Set Blue Office style")
        AddButton(setSilverStyle, "Set Silver Office style")
        AddButton(setBlackStyle, "Set Black Office style")
    End Sub

    Private Sub AddButton(ByVal button As Button, ByVal text As String)
        Me.panel.Controls.Add(button)
        button.Text = text
        button.AutoSize = True
    End Sub

    Friend WithEvents setBlueStyle As New Button()
    Friend WithEvents setSilverStyle As New Button()
    Friend WithEvents setBlackStyle As New Button()

#End Region

    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New Office2007StyleDemo())
    End Sub
End Class
継承階層

System.Object
   System.ValueType
      System.Enum
         GrapeCity.Win.MultiRow.Office2007Style

参照

GrapeCity.Win.MultiRow 名前空間
Office2007Style プロパティ
ScrollBarOffice2007Style プロパティ
SplitOffice2007Style プロパティ

 

 


© 2008-2015 GrapeCity inc. All rights reserved.