TreeView.StateImageList Propriedade

Definição

Obtém ou define a lista de imagens que é usada para indicar o estado de e TreeView dos 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; }
member this.StateImageList : System.Windows.Forms.ImageList with get, set
Public Property StateImageList As ImageList

Valor de Propriedade

É ImageList usado para indicar o estado do TreeView e dos seus nós.

Exemplos

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

    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

Observações

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 apresentadas são TreeView 16 x 16 píxeis por defeito. Definir a ImageSize propriedade do StateImageList testamento não afeta a forma como as imagens são exibidas. No entanto, as imagens de estado são redimensionadas de acordo com a definição de DPI do sistema quando o ficheiro app.config contém a seguinte entrada:

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

Quando a CheckBoxes propriedade de a TreeView é definida como true e a StateImageList propriedade está definida, cada TreeNode uma que está contida em TreeView exibe a primeira e a segunda imagem de para StateImageList indicar um estado não verificado ou verificado, respetivamente. Deves 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 uma imagem de estado definida.

Aplica-se a