PowerTools InputMan for Windows Forms 8.0J
Items プロパティ (GcListBox)
使用例 

リストの項目のコレクションを取得します。
構文
Public ReadOnly Property Items As ListItemCollection
public ListItemCollection Items {get;}

プロパティ値

項目のコレクションを表すListItemCollectionオブジェクト。
解説
このプロパティを使用すると、現在GcListBoxに格納されている項目のリストへの参照を取得できます。この参照を使用して、コレクション内の項目を追加または削除したり、項目数を確認したりできます。項目コレクションで実行できる操作の詳細については、ListItemCollectionクラスリファレンスのトピックを参照してください。

また、DataSource プロパティを使用してGcListBoxの項目を操作することもできます。DataSource プロパティを使用してGcListBoxに項目を追加する場合は、Items プロパティを使用してGcListBoxの項目を表示することはできますが、ListItemCollectionのメソッドを使用してリストの項目を追加または削除することはできません。

使用例
複数のカラムに複数のアイテムを表示する GcListBox コントロールを作成するコード例を次に示します。
//  Please use the following namespace
//  using System.Windows.Forms;
//  using GrapeCity.Win.Editors;

public void SetItemsSettings()
{
    // Creates the GcListBox control.
    GcListBox gcListBox1 = new GcListBox();

    // Creates the ListColumns.
    ListColumn listColumn1 = new ListColumn();
    ListColumn listColumn2 = new ListColumn();

    // Createst eh ListItems and SubItems.
    ListItem listItem1 = new ListItem();
    SubItem subItem1 = new SubItem();
    SubItem subItem2 = new SubItem();
    ListItem listItem2 = new ListItem();
    SubItem subItem3 = new SubItem();
    SubItem subItem4 = new SubItem();
    ListItem listItem3 = new ListItem();
    SubItem subItem5 = new SubItem();
    SubItem subItem6 = new SubItem();
    ListItem listItem4 = new ListItem();
    SubItem subItem7 = new SubItem();
    SubItem subItem8 = new SubItem();
    ListItem listItem5 = new ListItem();
    SubItem subItem9 = new SubItem();
    SubItem subItem10 = new SubItem();
    
    // Sets the ListItems' settings.
    subItem1.Value = "111-1111-1111";
    subItem2.Value = "AAAAA";
    listItem1.SubItems.AddRange(new SubItem[] {
    subItem1,
    subItem2});
    subItem3.Value = "222-2222-2222";
    subItem4.Value = "BBBBB";
    listItem2.SubItems.AddRange(new SubItem[] {
    subItem3,
    subItem4});
    subItem5.Value = "333-3333-3333";
    subItem6.Value = "CCCCC";
    listItem3.SubItems.AddRange(new SubItem[] {
    subItem5,
    subItem6});
    subItem7.Value = "444-4444-4444";
    subItem8.Value = "DDDDD";
    listItem4.SubItems.AddRange(new SubItem[] {
    subItem7,
    subItem8});
    subItem9.Value = "555-5555-5555";
    subItem10.Value = "EEEEE";
    listItem5.SubItems.AddRange(new SubItem[] {
    subItem9,
    subItem10});

    // Adds the columns.
    gcListBox1.Columns.AddRange(new ListColumn[] { listColumn1, listColumn2 });

    // Adds the items.
    gcListBox1.Items.AddRange(new ListItem[] {
    listItem1,
    listItem2,
    listItem3,
    listItem4,
    listItem5});
}
'  Please use the following namespace
'  Imports System.Windows.Forms;
'  Imports GrapeCity.Win.Editors;

Public Sub SetItemsSettings()
    ' Creates the GcListBox control.
    Dim gcListBox1 As New GcListBox()

    ' Creates the ListColumns.
    Dim listColumn1 As New ListColumn()
    Dim listColumn2 As New ListColumn()

    ' Createst eh ListItems and SubItems.
    Dim listItem1 As New ListItem()
    Dim subItem1 As New SubItem()
    Dim subItem2 As New SubItem()
    Dim listItem2 As New ListItem()
    Dim subItem3 As New SubItem()
    Dim subItem4 As New SubItem()
    Dim listItem3 As New ListItem()
    Dim subItem5 As New SubItem()
    Dim subItem6 As New SubItem()
    Dim listItem4 As New ListItem()
    Dim subItem7 As New SubItem()
    Dim subItem8 As New SubItem()
    Dim listItem5 As New ListItem()
    Dim subItem9 As New SubItem()
    Dim subItem10 As New SubItem()

    ' Sets the ListItems' settings.
    subItem1.Value = "111-1111-1111"
    subItem2.Value = "AAAAA"
    listItem1.SubItems.AddRange(New SubItem() {subItem1, subItem2})
    subItem3.Value = "222-2222-2222"
    subItem4.Value = "BBBBB"
    listItem2.SubItems.AddRange(New SubItem() {subItem3, subItem4})
    subItem5.Value = "333-3333-3333"
    subItem6.Value = "CCCCC"
    listItem3.SubItems.AddRange(New SubItem() {subItem5, subItem6})
    subItem7.Value = "444-4444-4444"
    subItem8.Value = "DDDDD"
    listItem4.SubItems.AddRange(New SubItem() {subItem7, subItem8})
    subItem9.Value = "555-5555-5555"
    subItem10.Value = "EEEEE"
    listItem5.SubItems.AddRange(New SubItem() {subItem9, subItem10})

    ' Adds the columns.
    gcListBox1.Columns.AddRange(New ListColumn() {listColumn1, listColumn2})

    ' Adds the items.
    gcListBox1.Items.AddRange(New ListItem() {listItem1, listItem2, listItem3, listItem4, listItem5})
End Sub
参照

GcListBox クラス
GcListBox メンバ

 

 


© 2004-2015 GrapeCity inc. All rights reserved.