TreeView.StateImageList Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the image list that is used to indicate the state of the TreeView and its nodes.
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
Property Value
The ImageList used for indicating the state of the TreeView and its nodes.
Examples
The following code example demonstrates the StateImageList property. To run this example, paste the code into a Windows Form and call InitializeCheckTreeView
from the form's constructor or Load event handler.
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
Remarks
To indicate the state of a TreeNode, set the StateImageList property and also set the StateImageKey or StateImageIndex property for each TreeNode.
The state images displayed in the TreeView are 16 x 16 pixels by default. Setting the ImageSize property of the StateImageList will have no effect on how the images are displayed. However, the state images are resized according to the system DPI setting when the app.config file contains the following entry:
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
When the CheckBoxes property of a TreeView is set to true
and the StateImageList property is set, each TreeNode that is contained in the TreeView displays the first and second images from the StateImageList to indicate an unchecked or checked state, respectively. You should set the StateImageList property before you add nodes to the TreeView to prevent state images being shown at design time for nodes that do not have a state image set.
Applies to
Povratne informacije
https://aka.ms/ContentUserFeedback.
Kmalu na voljo: V letu 2024 bomo ukinili storitev Težave v storitvi GitHub kot mehanizem za povratne informacije za vsebino in jo zamenjali z novim sistemom za povratne informacije. Za več informacij si oglejte:Pošlji in prikaži povratne informacije za