TreeView.StateImageList Propriedade

Definição

Obtém ou define a lista de imagens que é usada para indicar o estado da TreeView e seus nós.

public:
 property System::Windows::Forms::ImageList ^ StateImageList { System::Windows::Forms::ImageList ^ get(); void set(System::Windows::Forms::ImageList ^ value); };
public System.Windows.Forms.ImageList StateImageList { get; set; }
public System.Windows.Forms.ImageList? StateImageList { get; set; }
member this.StateImageList : System.Windows.Forms.ImageList with get, set
Public Property StateImageList As ImageList

Valor da propriedade

A ImageList usada para indicar o estado da TreeView e seus nós.

Exemplos

O exemplo de código a seguir demonstra a StateImageList propriedade . Para executar este exemplo, cole o código em um Windows Form e chame InitializeCheckTreeView do construtor ou Load manipulador de eventos do formulário.

    TreeView^ checkTreeView;
private:
    void InitializeCheckTreeView()
    {
        checkTreeView = gcnew TreeView();

        // Show check boxes for the TreeView. This
        // will cause the StateImageList to be used.
        checkTreeView->CheckBoxes = true;

        // Create the StateImageList and add two images.
        checkTreeView->StateImageList = gcnew ImageList();
        checkTreeView->StateImageList->Images->Add(SystemIcons::Question);
        checkTreeView->StateImageList->Images->Add(SystemIcons::Exclamation);

        // Add some nodes to the TreeView and the TreeView to the form.
        checkTreeView->Nodes->Add("Node1");
        checkTreeView->Nodes->Add("Node2");
        this->Controls->Add(checkTreeView);
    }
TreeView checkTreeView;
private void InitializeCheckTreeView()
{
    checkTreeView = new TreeView();
    
    // Show check boxes for the TreeView. This
    // will cause the StateImageList to be used.
    checkTreeView.CheckBoxes = true;

    // Create the StateImageList and add two images.
    checkTreeView.StateImageList = new ImageList();
    checkTreeView.StateImageList.Images.Add(SystemIcons.Question);
    checkTreeView.StateImageList.Images.Add(SystemIcons.Exclamation);
    
    // Add some nodes to the TreeView and the TreeView to the form.
    checkTreeView.Nodes.Add("Node1");
    checkTreeView.Nodes.Add("Node2");
    this.Controls.Add(checkTreeView);
}
Private checkTreeView As TreeView

Private Sub InitializeCheckTreeView() 
    checkTreeView = New TreeView()
    
    ' Show check boxes for the TreeView.
    checkTreeView.CheckBoxes = True
    
    ' Create the StateImageList and add two images.
    checkTreeView.StateImageList = New ImageList()
    checkTreeView.StateImageList.Images.Add(SystemIcons.Question)
    checkTreeView.StateImageList.Images.Add(SystemIcons.Exclamation)
    
    ' Add some nodes to the TreeView and the TreeView to the form.
    checkTreeView.Nodes.Add("Node1")
    checkTreeView.Nodes.Add("Node2")
    Me.Controls.Add(checkTreeView)

End Sub

Comentários

Para indicar o estado de um TreeNode, defina a StateImageList propriedade e também defina a StateImageKey propriedade ou StateImageIndex para cada TreeNode.

As imagens de estado exibidas no TreeView são 16 x 16 pixels por padrão. Definir a ImageSize propriedade do StateImageList não terá efeito sobre como as imagens são exibidas. No entanto, as imagens de estado são redimensionadas de acordo com a configuração de DPI do sistema quando o arquivo app.config contém a seguinte entrada:

<appSettings>  
  <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />  
</appSettings>  

Quando a CheckBoxes propriedade de um TreeView é definida true como e a StateImageList propriedade é definida, cada TreeNode uma contida no TreeView exibe a primeira e a segunda imagens do StateImageList para indicar um estado desmarcado ou verificado, respectivamente. Você deve definir a StateImageList propriedade antes de adicionar nós ao TreeView para evitar que imagens de estado sejam mostradas em tempo de design para nós que não têm um conjunto de imagens de estado.

Aplica-se a