PowerTools InputMan for Windows Forms 8.0J
FindObject(Object,Int32) メソッド
使用例 

検索項目を表すオブジェクト。
検索対象となるカラムのインデックスを表すSystem.Int32値。
指定されたオブジェクトに一致するリスト項目を検索します。
構文
Public Overloads Function FindObject( _
   ByVal obj As Object, _
   ByVal findTargetColumnIndex As Integer _
) As MatchedComboItemCollection

パラメータ

obj
検索項目を表すオブジェクト。
findTargetColumnIndex
検索対象となるカラムのインデックスを表すSystem.Int32値。

戻り値の型

見つかった項目を格納しているMatchedListItemCollection
解説
objパラメータは、コンボボックスリストの項目に関連付けられているオブジェクトと比較するオブジェクトです。この検索では、オブジェクトの最初位置から部分的に一致するオブジェクトを検索し、findTargetColumnIndexで指定したカラムにある、指定された文字列と一致するすべての項目を戻します。そうすると、ListItemCollection.Removeメソッドを使用して検索オブジェクトを含む項目を削除したり、項目のテキストを変更するなどのタスクを実行することができます。指定されたオブジェクトを検索した後、GcMaskedComboBoxにあるオブジェクトのほかのインスタンスを検索するには、GcMaskedComboBox内の開始位置を指定したパラメータがあるFindString(String,Int32,Int32)メソッドを使用します。部分一致ではなく完全に一致するオブジェクトを検索する場合は、FindStringExact(String,Int32)メソッドを使用します。
使用例
FindObjectメソッドの使用方法を示すコード例を次に示します。
'  Please use the following namespace
'  Imports System.Windows.Forms;
'  Imports GrapeCity.Win.Editors;

Public Sub FindObjectFromGcMaskedComboBox()
    ' Creates the GcMaskedComboBox 
    Dim gcMaskedComboBox1 As New GcMaskedComboBox()
    ' Creates items for the GcMaskedComboBox.
    Me.CreateItems(gcMaskedComboBox1)
    ' The FindObject can find out all the SubItems with the "001" value.
    Dim collection As MatchedComboItemCollection = gcMaskedComboBox1.FindObject("001", 1)
    ' This method can find out the first SubItem which has the "001" value.
    Dim index As Integer = gcMaskedComboBox1.FindObject("001", -1, 1)
End Sub

Public Sub CreateItems(ByVal gcMaskedComboBox As GcMaskedComboBox)
    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()

    Dim listColumn1 As New ListColumn()
    Dim listColumn2 As New ListColumn()

    subItem1.Value = "AA"
    subItem2.Value = "001"
    listItem1.SubItems.AddRange(New SubItem() {subItem1, subItem2})
    subItem3.Value = "BB"
    subItem4.Value = "002"
    listItem2.SubItems.AddRange(New SubItem() {subItem3, subItem4})
    subItem5.Value = "CC"
    subItem6.Value = "003"
    listItem3.SubItems.AddRange(New SubItem() {subItem5, subItem6})
    subItem7.Value = "AA"
    subItem8.Value = "004"
    listItem4.SubItems.AddRange(New SubItem() {subItem7, subItem8})
    subItem9.Value = "DD"
    subItem10.Value = "001"
    listItem5.SubItems.AddRange(New SubItem() {subItem9, subItem10})
    gcMaskedComboBox.Items.AddRange(New ListItem() {listItem1, listItem2, listItem3, listItem4, listItem5})
    gcMaskedComboBox.ListColumns.AddRange(New ListColumn() {listColumn1, listColumn2})
End Sub
//  Please use the following namespace
//  using System.Windows.Forms;
//  using GrapeCity.Win.Editors;

public void FindObjectFromGcComboBox()
{
    // Creates the GcMaskedComboBox 
    GcMaskedComboBox gcMaskedComboBox1 = new GcMaskedComboBox();
    // Creates items for the GcMaskedComboBox.
    this.CreateItems(gcMaskedComboBox1);
    // The FindObject can find out all the SubItems with the "001" value.
    MatchedComboItemCollection collection = gcMaskedComboBox1.FindObject("001", 1);
    // This method can find out the first SubItem which has the "001" value.
    int index = gcMaskedComboBox1.FindObject("001", -1, 1);
}

public void CreateItems(GcMaskedComboBox gcMaskedComboBox)
{
    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();

    ListColumn listColumn1 = new ListColumn();
    ListColumn listColumn2 = new ListColumn();

    subItem1.Value = "AA";
    subItem2.Value = "001";
    listItem1.SubItems.AddRange(new SubItem[] {
    subItem1,
    subItem2});
    subItem3.Value = "BB";
    subItem4.Value = "002";
    listItem2.SubItems.AddRange(new SubItem[] {
    subItem3,
    subItem4});
    subItem5.Value = "CC";
    subItem6.Value = "003";
    listItem3.SubItems.AddRange(new SubItem[] {
    subItem5,
    subItem6});
    subItem7.Value = "AA";
    subItem8.Value = "004";
    listItem4.SubItems.AddRange(new SubItem[] {
    subItem7,
    subItem8});
    subItem9.Value = "DD";
    subItem10.Value = "001";
    listItem5.SubItems.AddRange(new SubItem[] {
    subItem9,
    subItem10});
    gcMaskedComboBox.Items.AddRange(new ListItem[] {
    listItem1,
    listItem2,
    listItem3,
    listItem4,
    listItem5});
    gcMaskedComboBox.ListColumns.AddRange(new ListColumn[] { listColumn1, listColumn2 });
}
参照

GcMaskedComboBox クラス
GcMaskedComboBox メンバ
オーバーロード一覧

 

 


© 2004-2015 GrapeCity inc. All rights reserved.