ListViewItem.IndentCount プロパティ

定義

ListViewItem のインデント幅として使用する小さいイメージの幅の数を取得または設定します。Gets or sets the number of small image widths by which to indent the ListViewItem.

public:
 property int IndentCount { int get(); void set(int value); };
public int IndentCount { get; set; }
member this.IndentCount : int with get, set
Public Property IndentCount As Integer

プロパティ値

Int32

ListViewItem のインデント幅として使用する小さいイメージの幅の数。The number of small image widths by which to indent the ListViewItem.

例外

IndentCount を設定する場合に、指定された数が 0 未満です。When setting IndentCount, the number specified is less than 0.

プロパティを設定する方法を次のコード例に示し IndentCount ます。The following code example demonstrates how to set the IndentCount property. この例を実行するには、次のコードを Windows フォームに貼り付け、 InitializeIndentedListViewItems フォームのコンストラクターまたは Load イベント処理メソッドからメソッドを呼び出します。To run this example, paste the following code into a Windows Form and call the InitializeIndentedListViewItems method from the form's constructor or Load event-handling method.

ListView indentedListView;

private void InitializeIndentedListViewItems()
{
    indentedListView = new ListView();
    indentedListView.Width = 200;

    // View must be set to Details to use IndentCount.
    indentedListView.View = View.Details;
    indentedListView.Columns.Add("Indented Items", 150);
   
    // Create an image list and add an image.
    ImageList list = new ImageList();
    list.Images.Add(new Bitmap(typeof(Button), "Button.bmp"));

    // SmallImageList must be set when using IndentCount.
    indentedListView.SmallImageList = list;

    ListViewItem item1 = new ListViewItem("Click", 0);
    item1.IndentCount = 1;
    ListViewItem item2 = new ListViewItem("OK", 0);
    item2.IndentCount = 2;
    ListViewItem item3 = new ListViewItem("Cancel", 0);
    item3.IndentCount = 3;
    indentedListView.Items.AddRange(new ListViewItem[] { item1, item2, item3 });

    // Add the controls to the form.
    this.Controls.Add(indentedListView);
}
Private indentedListView As ListView


Private Sub InitializeIndentedListViewItems() 
    indentedListView = New ListView()
    indentedListView.Width = 200
    
    ' View must be set to Details to use IndentCount.
    indentedListView.View = View.Details
    indentedListView.Columns.Add("Indented Items", 150)
    
    ' Create an image list and add an image.
    Dim list As New ImageList()
    list.Images.Add(New Bitmap(GetType(Button), "Button.bmp"))
    
    ' SmallImageList must be set when using IndentCount.
    indentedListView.SmallImageList = list
    
    Dim item1 As New ListViewItem("Click", 0)
    item1.IndentCount = 1
    Dim item2 As New ListViewItem("OK", 0)
    item2.IndentCount = 2
    Dim item3 As New ListViewItem("Cancel", 0)
    item3.IndentCount = 3
    indentedListView.Items.AddRange(New ListViewItem() {item1, item2, item3})
    
    ' Add the controls to the form.
    Me.Controls.Add(indentedListView)

End Sub

注釈

プロパティは、を含んでいる IndentCount View のプロパティがに設定され、 ListView Details SmallImageList のプロパティ ListView が設定されている場合にのみ使用できます。The IndentCount property can be used only when the View property of the containing ListView is set to Details, and the SmallImageList property of the ListView is set.

適用対象