Aracılığıyla paylaş


ColumnWidthChangingEventArgs.NewWidth Özellik

Tanım

Sütun için yeni genişliği alır veya ayarlar.

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

Özellik Değeri

Sütunun yeni genişliği.

Örnekler

Aşağıdaki kod örneğinde bu üyenin kullanımı gösterilmektedir. Örnekte, olay işleyicisi olayın oluşumunu ListView.ColumnWidthChanging bildirir. Bu rapor, olayın ne zaman gerçekleştiğini öğrenmenize yardımcı olur ve hata ayıklamada size yardımcı olabilir. Birden çok olayı veya sık gerçekleşen olayları raporlamak için, iletisini ile MessageBox.Show değiştirmeyi Console.WriteLine veya çok satırlı TextBoxbir iletiye eklemeyi göz önünde bulundurun.

Örnek kodu çalıştırmak için, adlı ListViewtürünün ListView1 bir örneğini içeren bir projeye yapıştırın. Ardından olay işleyicisinin olayla ilişkilendirildiğinden ListView.ColumnWidthChanging emin olun.

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

Açıklamalar

Olayı teslim ederken ColumnWidthChanging özelliği, NewWidth yeni genişliğin uygulamanızın gereksinimlerini karşılayıp karşılamadığını doğrulamanızı ve genişliği ayarlamanızı veya değilse olayı iptal etmenizi sağlar.

Şunlara uygulanır