GrapeCity.Win.Containers 名前空間 : GcGroupBoxControlBase クラス |
Public MustInherit Class GcGroupBoxControlBase Inherits GrapeCity.Win.Common.PlusPakControlBase
public abstract class GcGroupBoxControlBase : GrapeCity.Win.Common.PlusPakControlBase
このクラスは、GcCheckedGroupBoxコントロールとGcRadioGroupBoxコントロールの基本機能を実装します。ユーザーがこのクラスから継承して独自のグループボックスコントロールを実装することはできません。
このクラスによって実装される基本機能は次のとおりです。
また、GcCheckedGroupBoxまたはGcRadioGroupBoxが折りたたまれるとCollapsingイベントとCollapsedイベントが発生し、GcCheckedGroupBoxまたはGcRadioGroupBoxが展開されるとExpandingイベントとExpandedイベントが発生します。
GcCheckedGroupBoxクラスとGcRadioGroupBoxクラスはGcGroupBoxControlBaseから継承され、それぞれの固有の子項目に関連する特有の機能を実装します。詳細な説明については、各クラスのトピックを参照してください。
次のサンプルコードは、派生クラスのGcRadioGroupBoxを作成して項目を5つ追加し、GcGroupBoxControlBase.ItemSettingsプロパティを使用して項目の外観をカスタマイズします。また、GcGroupBoxControlBase.LayoutSettingsプロパティを使用してレイアウト特性を設定し、GcGroupBoxControlBase.HeaderSettingsプロパティを使用してヘッダの外観をカスタマイズします。さらに、ExpandedイベントとCollapsedイベントのイベントハンドラを追加し、ヘッダのテキストを更新しています。このサンプルコードを実行するには、以下のコードをSystem.Windows.Forms.Formプロジェクトに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出します。
private void CreateMyGcRadioGroupBox() { GcRadioGroupBox gcRadioGroupBox1 = new GcRadioGroupBox(); // Set gcRadioGroupBox1's location. gcRadioGroupBox1.Location = new Point(10, 10); // Set up the group style for this control. gcRadioGroupBox1.GroupStyle = GroupStyle.TopLine; // Set HeaderType and Header's text. gcRadioGroupBox1.HeaderType = HeaderType.ExpanderAndText; gcRadioGroupBox1.Text = "&Collapse All"; // Enable the header and items to support the access key. gcRadioGroupBox1.UseMnemonic = true; // Use Flat theme appearance to draw gcRadioGroupBox1. gcRadioGroupBox1.FlatStyle = GrapeCity.Win.Common.FlatStyleEx.Flat; // Create some radio button items. RadioButtonItem[] items = new RadioButtonItem[] { new RadioButtonItem("item&1"), new RadioButtonItem("item&2"), new RadioButtonItem("item&3"), new RadioButtonItem("item&4"), new RadioButtonItem("item&5"), }; // Add some items. gcRadioGroupBox1.Items.AddRange(items); // Customize the appearance of header through HeaderSetting. gcRadioGroupBox1.HeaderSettings.ForeColor = Color.Tomato; gcRadioGroupBox1.HeaderSettings.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); gcRadioGroupBox1.HeaderSettings.TextEffect = GrapeCity.Win.Common.TextEffect.Raised; // Customize the appearance of items through ItemSettings. gcRadioGroupBox1.ItemSettings.ForeColor = Color.Blue; gcRadioGroupBox1.ItemSettings.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); gcRadioGroupBox1.ItemSettings.TextEffect = GrapeCity.Win.Common.TextEffect.Raised; // Customize the layout of items through LayoutSettings. gcRadioGroupBox1.LayoutSettings.LayoutMode = LayoutMode.Table; gcRadioGroupBox1.LayoutSettings.Orientation = System.Windows.Forms.Orientation.Vertical; gcRadioGroupBox1.LayoutSettings.RowCount = 3; gcRadioGroupBox1.LayoutSettings.HorizontalAdjustment = GrapeCity.Win.Containers.LineAdjustment.Average; gcRadioGroupBox1.LayoutSettings.VerticalAdjustment = GrapeCity.Win.Containers.LineAdjustment.Average; // Set gradient effect for gcRadioGroupBox1. gcRadioGroupBox1.GradientEffect = new GrapeCity.Win.Common.GradientEffect( GrapeCity.Win.Common.GradientStyle.DiagonalDown, GrapeCity.Win.Common.GradientDirection.NotSet, System.Drawing.Color.White, System.Drawing.Color.Bisque); // Set pattern effect for gcRadioGroupBox1. gcRadioGroupBox1.PatternEffect = new GrapeCity.Win.Common.PatternEffect( GrapeCity.Win.Common.PatternStyle.DottedGrid, System.Drawing.Color.LightPink); // Update the text after gcRadioGroupBox1 expand or collapse. gcRadioGroupBox1.Expanded += new EventHandler(GcRadioGroupBox1_Expanded); gcRadioGroupBox1.Collapsed += new EventHandler(GcRadioGroupBox1_Collapsed); // Change the item appearance when item is checked or unchecked. gcRadioGroupBox1.CheckedItemChanged += new EventHandler<CheckedItemChangedEventArgs>(GcRadioGroupBox1_CheckedItemChanged); // Add gcRadioGroupBo1 to the form. this.Controls.Add(gcRadioGroupBox1); } private void GcRadioGroupBox1_CheckedItemChanged(object sender, CheckedItemChangedEventArgs e) { if (e.CurrentCheckedItem != null) { // Use special styles for checked items. e.CurrentCheckedItem.ForeColor = Color.Red; e.CurrentCheckedItem.Font = new Font(e.CurrentCheckedItem.Font, FontStyle.Bold); } if (e.OriginalCheckedItem != null) { // Reset these properties will cause the properties to retreive their values from gcRadioGroupBox1. e.OriginalCheckedItem.ForeColor = Color.Empty; e.OriginalCheckedItem.Font = null; } } private void GcRadioGroupBox1_Collapsed(object sender, EventArgs e) { (sender as GcRadioGroupBox).Text = "&Expand All"; } private void GcRadioGroupBox1_Expanded(object sender, EventArgs e) { (sender as GcRadioGroupBox).Text = "&Collapse All"; }
Private Sub CreateMyGcRadioGroupBox() Dim gcRadioGroupBox1 As New GcRadioGroupBox() ' Set gcRadioGroupBox1's location. gcRadioGroupBox1.Location = New Point(10, 10) ' Set up the group style for this control. gcRadioGroupBox1.GroupStyle = GroupStyle.TopLine ' Set HeaderType and Header's text. gcRadioGroupBox1.HeaderType = HeaderType.ExpanderAndText gcRadioGroupBox1.Text = "&Collapse All" ' Enable the header and items to support the access key. gcRadioGroupBox1.UseMnemonic = True ' Use Flat theme appearance to draw gcRadioGroupBox1. gcRadioGroupBox1.FlatStyle = FlatStyleEx.Flat ' Create some radio button items. Dim items As RadioButtonItem() = New RadioButtonItem() {New RadioButtonItem("item&1"), New RadioButtonItem("item&2"), New RadioButtonItem("item&3"), New RadioButtonItem("item&4"), New RadioButtonItem("item&5")} ' Add some items. gcRadioGroupBox1.Items.AddRange(items) ' Customize the appearance of header through HeaderSetting. gcRadioGroupBox1.HeaderSettings.ForeColor = Color.Tomato gcRadioGroupBox1.HeaderSettings.Font = New System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) gcRadioGroupBox1.HeaderSettings.TextEffect = TextEffect.Raised ' Customize the appearance of items through ItemSettings. gcRadioGroupBox1.ItemSettings.ForeColor = Color.Blue gcRadioGroupBox1.ItemSettings.Font = New System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) gcRadioGroupBox1.ItemSettings.TextEffect = TextEffect.Raised ' Customize the layout of items through LayoutSettings. gcRadioGroupBox1.LayoutSettings.LayoutMode = LayoutMode.Table gcRadioGroupBox1.LayoutSettings.Orientation = System.Windows.Forms.Orientation.Vertical gcRadioGroupBox1.LayoutSettings.RowCount = 3 gcRadioGroupBox1.LayoutSettings.HorizontalAdjustment = LineAdjustment.Average gcRadioGroupBox1.LayoutSettings.VerticalAdjustment = LineAdjustment.Average ' Set gradient effect for gcRadioGroupBox1. gcRadioGroupBox1.GradientEffect = New GradientEffect(GradientStyle.DiagonalDown, GradientDirection.NotSet, System.Drawing.Color.White, System.Drawing.Color.Bisque) ' Set pattern effect for gcRadioGroupBox1. gcRadioGroupBox1.PatternEffect = New PatternEffect(PatternStyle.DottedGrid, System.Drawing.Color.LightPink) ' Update the text after gcRadioGroupBox1 expand or collapse. AddHandler gcRadioGroupBox1.Expanded, AddressOf GcRadioGroupBox1_Expanded AddHandler gcRadioGroupBox1.Collapsed, AddressOf GcRadioGroupBox1_Collapsed ' Change the item appearance when item is checked or unchecked. AddHandler gcRadioGroupBox1.CheckedItemChanged, AddressOf GcRadioGroupBox1_CheckedItemChanged ' Add gcRadioGroupBo1 to the form. Me.Controls.Add(gcRadioGroupBox1) End Sub Private Sub GcRadioGroupBox1_CheckedItemChanged(ByVal sender As Object, ByVal e As CheckedItemChangedEventArgs) If e.CurrentCheckedItem IsNot Nothing Then ' Use special styles for checked items. e.CurrentCheckedItem.ForeColor = Color.Red e.CurrentCheckedItem.Font = New Font(e.CurrentCheckedItem.Font, FontStyle.Bold) End If If e.OriginalCheckedItem IsNot Nothing Then ' Reset these properties will cause the properties to retreive their values from gcRadioGroupBox1. e.OriginalCheckedItem.ForeColor = Color.Empty e.OriginalCheckedItem.Font = Nothing End If End Sub Private Sub GcRadioGroupBox1_Collapsed(ByVal sender As Object, ByVal e As EventArgs) TryCast(sender, GcRadioGroupBox).Text = "&Expand All" End Sub Private Sub GcRadioGroupBox1_Expanded(ByVal sender As Object, ByVal e As EventArgs) TryCast(sender, GcRadioGroupBox).Text = "&Collapse All" End Sub
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
GrapeCity.Framework.Forms.FrameworkControl
GrapeCity.Framework.Views.Windows.ElementContainerControl
GrapeCity.Framework.Forms.ControlBase
GrapeCity.Win.Common.PlusPakControlBase
GrapeCity.Win.Containers.GcGroupBoxControlBase
GrapeCity.Win.Containers.GcCheckedGroupBox
GrapeCity.Win.Containers.GcRadioGroupBox
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