ColumnWidthChangingEventArgs.NewWidth Propriedade

Definição

Obtém ou define a nova largura da coluna.

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

Valor de Propriedade

A nova largura para a coluna.

Exemplos

O seguinte exemplo de código demonstra a utilização deste elemento. No exemplo, um gestor de eventos reporta a ocorrência do ListView.ColumnWidthChanging evento. Este relatório ajuda-o a saber quando o evento ocorre e pode ajudá-lo na depuração. Para reportar múltiplos eventos ou eventos que ocorrem frequentemente, considere substituir MessageBox.Show ou Console.WriteLine anexar a mensagem a uma multilinha TextBox.

Para executar o código de exemplo, cole-o num projeto que contenha uma instância do tipo ListView chamada ListView1. Depois, certifique-se de que o gestor de eventos está associado ao ListView.ColumnWidthChanging evento.

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

Observações

Ao tratar do ColumnWidthChanging evento, a NewWidth propriedade permite-lhe verificar se a nova largura cumpre os requisitos da sua aplicação e ajustar a largura ou cancelar o evento caso não o fizer.

Aplica-se a