ColumnWidthChangingEventArgs.NewWidth 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定欄位的新寬度。
public:
property int NewWidth { int get(); void set(int value); };
public int NewWidth { get; set; }
member this.NewWidth : int with get, set
Public Property NewWidth As Integer
屬性值
柱子的新寬度。
範例
以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 ListView.ColumnWidthChanging 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox。
要執行範例程式碼,請將其貼到包含一個 ListView 名為 ListView1的實例的專案中。 然後確保事件處理程式與事件 ListView.ColumnWidthChanging 相關聯。
private void ListView1_ColumnWidthChanging(Object sender, ColumnWidthChangingEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewWidth", e.NewWidth );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ColumnWidthChanging Event" );
}
Private Sub ListView1_ColumnWidthChanging(sender as Object, e as ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "NewWidth", e.NewWidth)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"ColumnWidthChanging Event")
End Sub
備註
在交付 ColumnWidthChanging 活動時,該 NewWidth 屬性允許您確認新寬度是否符合申請要求,若不符合則可調整寬度或取消活動。