GrapeCity.Win.Components 名前空間 > GcResize クラス : ControlResizing イベント |
Public Event ControlResizing As GcResizeEventHandler
public event GcResizeEventHandler ControlResizing
イベント ハンドラが、このイベントに関連するデータを含む、GcResizeEventArgs 型の引数を受け取りました。次の GcResizeEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
Control | GcResize コンポーネントによってそのフォントがサイズ変更されようとしているコントロールへの参照を取得します。 |
ResizeFontInfo | GcResize によって提供された、現在の Control のフォントサイズ変更に関する情報を取得します。 |
ResizeLayoutInfo | GcResize によって提供された、現在の Control のレイアウトサイズ変更に関する情報を取得します。 |
ResizeMode | GcResize が現在の Control をサイズ変更するためのサイズ変更モードを取得します。 |
次のサンプルコードは、System.Windows.Forms.ListView のサイズ変更動作を処理する方法を示します。ResizePolicy を実装することによってコントロールのサイズ変更動作を処理することもできます。
using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using GrapeCity.Win.Components; namespace GrapeCity.Win.PlusPak.SampleCodes_CS { public class GcResizeControlResizingEventDemo : Form { private GcResize gcResize1; private ListView listView1; private IContainer components; public GcResizeControlResizingEventDemo() { InitializeComponent(); // Set the view to show details. listView1.View = View.Details; // Allow the user to edit item text. listView1.LabelEdit = true; // Allow the user to rearrange columns. listView1.AllowColumnReorder = true; // Display check boxes. listView1.CheckBoxes = true; // Select the item and subitems when selection is made. listView1.FullRowSelect = true; // Display grid lines. listView1.GridLines = true; // Sort the items in the list in ascending order. listView1.Sorting = SortOrder.Ascending; // Create three items and three sets of subitems for each item. ListViewItem item1 = new ListViewItem("item1", 0); // Place a check mark next to the item. item1.Checked = true; item1.SubItems.Add("1"); item1.SubItems.Add("2"); item1.SubItems.Add("3"); ListViewItem item2 = new ListViewItem("item2", 1); item2.SubItems.Add("4"); item2.SubItems.Add("5"); item2.SubItems.Add("6"); ListViewItem item3 = new ListViewItem("item3", 0); // Place a check mark next to the item. item3.Checked = true; item3.SubItems.Add("7"); item3.SubItems.Add("8"); item3.SubItems.Add("9"); // Create columns for the items and subitems. // Width of -2 indicates auto-size. listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left); listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left); listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left); listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center); //Add the items to the ListView. listView1.Items.AddRange(new ListViewItem[] { item1, item2, item3 }); } private void InitializeComponent() { this.components = new Container(); this.gcResize1 = new GcResize(this.components); this.listView1 = new ListView(); ((ISupportInitialize)(this.gcResize1)).BeginInit(); this.SuspendLayout(); // // gcResize1 // this.gcResize1.ControlResizing += gcResize1_ControlResizing; this.gcResize1.Target = this; // // listView1 // this.listView1.CheckBoxes = true; this.listView1.Location = new Point(15, 26); this.listView1.Name = "listView1"; this.listView1.Size = new Size(229, 185); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; // // GcResize // this.ClientSize = new Size(284, 261); this.Controls.Add(this.listView1); this.Name = "GcResizeResizePolicyDemo"; ((ISupportInitialize)(this.gcResize1)).EndInit(); this.ResumeLayout(false); } private void gcResize1_ControlResizing(object sender, GcResizeEventArgs e) { var listView = e.Control as ListView; if (listView != null) { listView.SuspendLayout(); if (listView.Columns.Count > 0) { foreach (ColumnHeader column in listView.Columns) { column.Width = e.ResizeLayoutInfo.ScaleX(column.Width); } } listView.Bounds = e.ResizeLayoutInfo.TargetBounds; listView.ResumeLayout(true); e.Handled = true; return; } } [STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new GcResizeControlResizingEventDemo()); } } }
Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms Imports GrapeCity.Win.Components Namespace GrapeCity.Win.PlusPak.SampleCodes_VB Public Class GcResizeControlResizingEventDemo Inherits Form Private gcResize1 As GcResize Private listView1 As ListView Private components As IContainer Public Sub New() InitializeComponent() ' Set the view to show details. listView1.View = View.Details ' Allow the user to edit item text. listView1.LabelEdit = True ' Allow the user to rearrange columns. listView1.AllowColumnReorder = True ' Display check boxes. listView1.CheckBoxes = True ' Select the item and subitems when selection is made. listView1.FullRowSelect = True ' Display grid lines. listView1.GridLines = True ' Sort the items in the list in ascending order. listView1.Sorting = SortOrder.Ascending ' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check mark next to the item. item1.Checked = True item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim item2 As New ListViewItem("item2", 1) item2.SubItems.Add("4") item2.SubItems.Add("5") item2.SubItems.Add("6") Dim item3 As New ListViewItem("item3", 0) ' Place a check mark next to the item. item3.Checked = True item3.SubItems.Add("7") item3.SubItems.Add("8") item3.SubItems.Add("9") ' Create columns for the items and subitems. // Width of -2 indicates auto-size. listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left) listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center) 'Add the items to the ListView. listView1.Items.AddRange(New ListViewItem() {item1, item2, item3}) End Sub Private Sub InitializeComponent() Me.components = New Container() Me.gcResize1 = New GcResize(Me.components) Me.listView1 = New ListView() DirectCast(Me.gcResize1, ISupportInitialize).BeginInit() Me.SuspendLayout() ' ' gcResize1 ' AddHandler Me.gcResize1.ControlResizing, AddressOf gcResize1_ControlResizing Me.gcResize1.Target = Me ' ' listView1 ' Me.listView1.CheckBoxes = True Me.listView1.Location = New Point(15, 26) Me.listView1.Name = "listView1" Me.listView1.Size = New Size(229, 185) Me.listView1.TabIndex = 0 Me.listView1.UseCompatibleStateImageBehavior = False ' ' GcResize ' Me.ClientSize = New Size(284, 261) Me.Controls.Add(Me.listView1) Me.Name = "GcResizeResizePolicyDemo" DirectCast(Me.gcResize1, ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub Private Sub gcResize1_ControlResizing(sender As Object, e As GcResizeEventArgs) Dim listView = TryCast(e.Control, ListView) If listView IsNot Nothing Then listView.SuspendLayout() If listView.Columns.Count > 0 Then For Each column As ColumnHeader In listView.Columns column.Width = e.ResizeLayoutInfo.ScaleX(column.Width) Next End If listView.Bounds = e.ResizeLayoutInfo.TargetBounds listView.ResumeLayout(True) e.Handled = True Return End If End Sub End Class End Namespace
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