ListView.ColumnWidthChanging イベント
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ListView Dim handler As ColumnWidthChangingEventHandler AddHandler instance.ColumnWidthChanging, handler
public: event ColumnWidthChangingEventHandler^ ColumnWidthChanging { void add (ColumnWidthChangingEventHandler^ value); void remove (ColumnWidthChangingEventHandler^ value); }

このイベントを使用すると、ColumnWidthChangingEventArgs.NewWidth プロパティを使用して新しい列幅をチェックしたり、Cancel プロパティを true に設定して指定した場合にイベントをキャンセルしたりできます。

ColumnWidthChanging イベントを処理するコード例を次に示します。この例はまた、ColumnWidthChangingEventArgs.NewWidth メンバと Cancel メンバも示しています。この例を実行するには、コードを Windows フォームに貼り付けます。次に、フォームのコンストラクタまたは Load のイベント処理メソッドで InitializeListView1 を呼び出します。
Private WithEvents listView1 As New ListView() Private Sub InitializeListView1() ' Initialize a ListView in detail view and add some columns. listView1.View = View.Details listView1.Width = 200 listView1.Columns.Add("Column1") listView1.Columns.Add("Column2") Me.Controls.Add(listView1) End Sub ' Handle the ColumnWidthChangingEvent. Private Sub listView1_ColumnWidthChanging(ByVal sender As Object, _ ByVal e As ColumnWidthChangingEventArgs) _ Handles listView1.ColumnWidthChanging ' Check if the new width is too big or too small. If e.NewWidth > 100 OrElse e.NewWidth < 5 Then ' Cancel the event and inform the user if the new ' width does not meet the criteria. MessageBox.Show("Column width is too large or too small") e.Cancel = True End If End Sub
ListView listView1 = new ListView(); private void InitializeListView1() { // Initialize a ListView in detail view and add some columns. listView1.View = View.Details; listView1.Width = 200; listView1.Columns.Add("Column1"); listView1.Columns.Add("Column2"); // Associate a method with the ColumnWidthChangingEvent. listView1.ColumnWidthChanging += new ColumnWidthChangingEventHandler(listView1_ColumnWidthChanging); this.Controls.Add(listView1); } // Handle the ColumnWidthChangingEvent. private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e) { // Check if the new width is too big or too small. if (e.NewWidth > 100 || e.NewWidth < 5) { // Cancel the event and inform the user if the new // width does not meet the criteria. MessageBox.Show("Column width is too large or too small"); e.Cancel = true; } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からListView.ColumnWidthChanging イベントを検索する場合は、下記のリンクをクリックしてください。

- ListView.ColumnWidthChanging イベントのページへのリンク