GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 : HeaderCell クラス |
このクラスは、ColumnHeaderCell、CornerHeaderCell、RowHeaderCellなどの他のヘッダセルクラスの基本クラスです。カスタムの行ヘッダアイコンまたは列ヘッダグリフを作成するには、HeaderCellクラスから継承して、独自のアイコンまたはグリフを描画する機能を追加します。
継承時の注意:
HeaderCellから継承した派生クラスに新しいプロパティを追加するときは、必ずCloneメソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスのCloneメソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。
using System; using System.Windows.Forms; using System.Drawing; namespace GrapeCity.Win.MultiRow.SampleCode { public class HeaderCellDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new HeaderCellDemo()); } public HeaderCellDemo() { this.gcMultiRow1.Dock = DockStyle.Fill; this.Controls.Add(this.gcMultiRow1); this.Load += new EventHandler(Form1_Load); this.Size = new Size(400, 350); this.Text = "HeaderCell Demo"; } private void Form1_Load(object sender, EventArgs e) { Template template1 = new Template(); ColumnHeaderSection columnHeader1 = CreateColumnHeader(); template1.ColumnHeaders.Add(columnHeader1); template1.Row.Cells.AddRange(CreateCellsInRow()); template1.Row.Height = 21; ColumnFooterSection columnFooter1 = CreateColumnFooter(); template1.ColumnFooters.Add(columnFooter1); template1.Width = 196; gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 10; gcMultiRow1.ViewMode = ViewMode.Row; } private ColumnHeaderSection CreateColumnHeader() { ColumnHeaderSection columnHeader1 = new ColumnHeaderSection(); columnHeader1.Height = 20; HeaderCell headerCell1 = new HeaderCell(); headerCell1.Size = new Size(36, 20); //There will exist 4 gutters around the HeaderCell. headerCell1.GutterStyles = GutterStyles.All; headerCell1.HoverDirection = HoverDirection.None; //Click the HeaderCell, all rows will be selelected. headerCell1.SelectionMode = MultiRowSelectionMode.AllRows; //Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. headerCell1.FlatStyle = FlatStyle.Standard; headerCell1.UseVisualStyleBackColor = false; headerCell1.Style.BackColor = Color.DarkGoldenrod; ColumnHeaderCell columnHeaderCell1 = new ColumnHeaderCell(); columnHeaderCell1.Value = "Column1"; columnHeaderCell1.Size = new Size(80, 20); columnHeaderCell1.Location = new Point(headerCell1.Left + headerCell1.Width, 0); columnHeaderCell1.Ellipsis = MultiRowEllipsisMode.EllipsisEnd; columnHeaderCell1.EllipsisString = "...."; //The cell's right will draw one gutter. columnHeaderCell1.GutterStyles = GutterStyles.Right; //The cell's bottom will draw hover effect. columnHeaderCell1.HoverDirection = HoverDirection.Bottom; //Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. columnHeaderCell1.FlatStyle = FlatStyle.Standard; columnHeaderCell1.UseVisualStyleBackColor = false; columnHeaderCell1.Style.BackColor = Color.DarkGoldenrod; columnHeaderCell1.Style.SelectionBackColor = Color.LightBlue; ColumnHeaderCell columnHeaderCell2 = columnHeaderCell1.Clone() as ColumnHeaderCell; columnHeaderCell2.Location = new Point(columnHeaderCell1.Left + columnHeaderCell1.Width, 0); columnHeaderCell2.Value = "Column2"; columnHeader1.Cells.AddRange(new Cell[] { headerCell1, columnHeaderCell1, columnHeaderCell2 }); return columnHeader1; } private ColumnFooterSection CreateColumnFooter() { ColumnFooterSection columnFooter1 = new ColumnFooterSection(); columnFooter1.Height = 20; HeaderCell headerCell1 = new HeaderCell(); headerCell1.Size = new Size(36, 20); //There will exist 4 gutters around the HeaderCell. headerCell1.GutterStyles = GutterStyles.All; //The hover effect will not be drawn. headerCell1.HoverDirection = HoverDirection.None; headerCell1.SelectionMode = MultiRowSelectionMode.AllRows; HeaderCell headerCell2 = new HeaderCell(); headerCell2.Size = new Size(80, 21); headerCell2.Location = new Point(headerCell1.Left + headerCell1.Width, 0); //The cell's right will draw one gutter. headerCell2.GutterStyles = GutterStyles.Right; //The cell's top will draw hover effect. headerCell2.HoverDirection = HoverDirection.Top; headerCell2.SelectionMode = MultiRowSelectionMode.IntersectedCells; HeaderCell headerCell3 = headerCell2.Clone() as HeaderCell; headerCell3.Location = new Point(headerCell2.Left + headerCell2.Width, 0); columnFooter1.Cells.AddRange(new Cell[] { headerCell1, headerCell2, headerCell3 }); return columnFooter1; } private Cell[] CreateCellsInRow() { RowHeaderCell rowHeaderCell1 = new RowHeaderCell(); rowHeaderCell1.Size = new Size(36, 21); rowHeaderCell1.ValueFormat = "1"; //The cell's bottom will draw one gutter. rowHeaderCell1.GutterStyles = GutterStyles.Bottom; //The cell's right will draw hover effect. rowHeaderCell1.HoverDirection = HoverDirection.Right; //Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. rowHeaderCell1.FlatStyle = FlatStyle.Standard; rowHeaderCell1.UseVisualStyleBackColor = false; rowHeaderCell1.Style.BackColor = Color.DarkGoldenrod; rowHeaderCell1.Style.SelectionBackColor = Color.LightBlue; TextBoxCell textBoxCell1 = new TextBoxCell(); textBoxCell1.Size = new Size(80, 21); textBoxCell1.Location = new Point(rowHeaderCell1.Left + rowHeaderCell1.Width, 0); TextBoxCell textBoxCell2 = textBoxCell1.Clone() as TextBoxCell; textBoxCell2.Location = new Point(textBoxCell1.Left + textBoxCell1.Width, 0); Cell[] cells = new Cell[] { rowHeaderCell1, textBoxCell1, textBoxCell2 }; return cells; } } }
Imports System Imports System.Windows.Forms Imports System.Drawing Imports GrapeCity.Win.MultiRow Public Class HeaderCellDemo Inherits Form Private gcMultiRow1 As New GcMultiRow() <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New HeaderCellDemo()) End Sub Public Sub New() Me.gcMultiRow1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcMultiRow1) Me.Size = New Size(400, 350) Me.Text = "HeaderCell Demo" End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim template1 As New Template() Dim columnHeader1 As ColumnHeaderSection = CreateColumnHeader() template1.ColumnHeaders.Add(columnHeader1) template1.Row.Cells.AddRange(CreateCellsInRow()) template1.Row.Height = 21 Dim columnFooter1 As ColumnFooterSection = CreateColumnFooter() template1.ColumnFooters.Add(columnFooter1) template1.Width = 196 gcMultiRow1.Template = template1 gcMultiRow1.RowCount = 10 gcMultiRow1.ViewMode = ViewMode.Row End Sub Private Function CreateColumnHeader() As ColumnHeaderSection Dim columnHeader1 As New ColumnHeaderSection() columnHeader1.Height = 20 Dim headerCell1 As New HeaderCell() headerCell1.Size = New Size(36, 20) 'There will exist 4 gutters around the HeaderCell. headerCell1.GutterStyles = GutterStyles.All headerCell1.HoverDirection = HoverDirection.None 'Click the HeaderCell, all rows will be selelected. headerCell1.SelectionMode = MultiRowSelectionMode.AllRows 'Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. headerCell1.FlatStyle = FlatStyle.Standard headerCell1.UseVisualStyleBackColor = False headerCell1.Style.BackColor = Color.DarkGoldenrod Dim columnHeaderCell1 As New ColumnHeaderCell() columnHeaderCell1.Value = "Column1" columnHeaderCell1.Size = New Size(80, 20) columnHeaderCell1.Location = New Point(headerCell1.Left + headerCell1.Width, 0) columnHeaderCell1.Ellipsis = MultiRowEllipsisMode.EllipsisEnd columnHeaderCell1.EllipsisString = "...." 'The cell's right will draw one gutter. columnHeaderCell1.GutterStyles = GutterStyles.Right 'The cell's bottom will draw hover effect. columnHeaderCell1.HoverDirection = HoverDirection.Bottom 'Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. columnHeaderCell1.FlatStyle = FlatStyle.Standard columnHeaderCell1.UseVisualStyleBackColor = False columnHeaderCell1.Style.BackColor = Color.DarkGoldenrod columnHeaderCell1.Style.SelectionBackColor = Color.LightBlue Dim columnHeaderCell2 As ColumnHeaderCell = TryCast(columnHeaderCell1.Clone(), ColumnHeaderCell) columnHeaderCell2.Location = New Point(columnHeaderCell1.Left + columnHeaderCell1.Width, 0) columnHeaderCell2.Value = "Column2" columnHeader1.Cells.AddRange(New Cell() {headerCell1, columnHeaderCell1, columnHeaderCell2}) Return columnHeader1 End Function Private Function CreateColumnFooter() As ColumnFooterSection Dim columnFooter1 As New ColumnFooterSection() columnFooter1.Height = 20 Dim headerCell1 As New HeaderCell() headerCell1.Size = New Size(36, 20) 'There will exist 4 gutters around the HeaderCell. headerCell1.GutterStyles = GutterStyles.All 'The hover effect will not be drawn. headerCell1.HoverDirection = HoverDirection.None headerCell1.SelectionMode = MultiRowSelectionMode.AllRows Dim headerCell2 As New HeaderCell() headerCell2.Size = New Size(80, 21) headerCell2.Location = New Point(headerCell1.Left + headerCell1.Width, 0) 'The cell's right will draw one gutter. headerCell2.GutterStyles = GutterStyles.Right 'The cell's top will draw hover effect. headerCell2.HoverDirection = HoverDirection.Top headerCell2.SelectionMode = MultiRowSelectionMode.IntersectedCells Dim headerCell3 As HeaderCell = TryCast(headerCell2.Clone(), HeaderCell) headerCell3.Location = New Point(headerCell2.Left + headerCell2.Width, 0) columnFooter1.Cells.AddRange(New Cell() {headerCell1, headerCell2, headerCell3}) Return columnFooter1 End Function Private Function CreateCellsInRow() As Cell() Dim rowHeaderCell1 As New RowHeaderCell() rowHeaderCell1.Size = New Size(36, 21) rowHeaderCell1.ValueFormat = "1" 'The cell's bottom will draw one gutter. rowHeaderCell1.GutterStyles = GutterStyles.Bottom 'The cell's right will draw hover effect. rowHeaderCell1.HoverDirection = HoverDirection.Right 'Use the CellStyle.BackColor to draw the HeaderCell's background, don's use the Vistual Style back color. rowHeaderCell1.FlatStyle = FlatStyle.Standard rowHeaderCell1.UseVisualStyleBackColor = False rowHeaderCell1.Style.BackColor = Color.DarkGoldenrod rowHeaderCell1.Style.SelectionBackColor = Color.LightBlue Dim textBoxCell1 As New TextBoxCell() textBoxCell1.Size = New Size(80, 21) textBoxCell1.Location = New Point(rowHeaderCell1.Left + rowHeaderCell1.Width, 0) Dim textBoxCell2 As TextBoxCell = TryCast(textBoxCell1.Clone(), TextBoxCell) textBoxCell2.Location = New Point(textBoxCell1.Left + textBoxCell1.Width, 0) Dim cells As Cell() = New Cell() {rowHeaderCell1, textBoxCell1, textBoxCell2} Return cells End Function End Class
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.MultiRow.Cell
GrapeCity.Win.MultiRow.HeaderCell
GrapeCity.Win.MultiRow.ColumnHeaderCell
GrapeCity.Win.MultiRow.CornerHeaderCell
GrapeCity.Win.MultiRow.RowHeaderCell