共用方式為


BindingManagerBase.GetItemProperties 方法

定義

取得資料來源的屬性描述項清單。

多載

GetItemProperties()

當在衍生類別中覆寫時,取得繫結的屬性描述項集合。

GetItemProperties(ArrayList, ArrayList)

使用指定的 ArrayList,取得繫結的屬性描述項集合。

GetItemProperties(Type, Int32, ArrayList, ArrayList)

取得由這個 BindingManagerBase 所管理項目的屬性清單。

GetItemProperties()

當在衍生類別中覆寫時,取得繫結的屬性描述項集合。

public:
 abstract System::ComponentModel::PropertyDescriptorCollection ^ GetItemProperties();
public:
 virtual System::ComponentModel::PropertyDescriptorCollection ^ GetItemProperties();
public abstract System.ComponentModel.PropertyDescriptorCollection GetItemProperties ();
public virtual System.ComponentModel.PropertyDescriptorCollection GetItemProperties ();
abstract member GetItemProperties : unit -> System.ComponentModel.PropertyDescriptorCollection
abstract member GetItemProperties : unit -> System.ComponentModel.PropertyDescriptorCollection
override this.GetItemProperties : unit -> System.ComponentModel.PropertyDescriptorCollection
Public MustOverride Function GetItemProperties () As PropertyDescriptorCollection
Public Overridable Function GetItemProperties () As PropertyDescriptorCollection

傳回

PropertyDescriptorCollection

PropertyDescriptorCollection,表示繫結的屬性描述項。

範例

下列程式碼範例會 GetItemProperties 使用 方法傳回 PropertyDescriptorCollection 。 此範例會 Name 使用 GetValue 的 方法列印目前 DataColumnPropertyDescriptor 和 值。

void ShowGetItemProperties()
{
   
   // Create a new DataTable and add two columns.
   DataTable^ dt = gcnew DataTable;
   dt->Columns->Add( "Name", Type::GetType( "System.String" ) );
   dt->Columns->Add( "ID", Type::GetType( "System.String" ) );
   
   // Add a row to the table.
   DataRow^ dr = dt->NewRow();
   dr[ "Name" ] = "Ann";
   dr[ "ID" ] = "AAA";
   dt->Rows->Add( dr );
   PropertyDescriptorCollection^ myPropertyDescriptors = this->BindingContext[ dt ]->GetItemProperties();
   PropertyDescriptor^ myPropertyDescriptor = myPropertyDescriptors[ "Name" ];
   Console::WriteLine( myPropertyDescriptor->Name );
   Console::WriteLine( myPropertyDescriptor->GetValue( dt->DefaultView[ 0 ] ) );
}
private void ShowGetItemProperties()
{
   // Create a new DataTable and add two columns.
   DataTable dt = new DataTable();
   dt.Columns.Add("Name", Type.GetType("System.String"));
   dt.Columns.Add("ID", Type.GetType("System.String"));
   // Add a row to the table.
   DataRow dr = dt.NewRow();
   dr["Name"] = "Ann";
   dr["ID"] = "AAA";
   dt.Rows.Add(dr);

   PropertyDescriptorCollection myPropertyDescriptors = 
   this.BindingContext[dt].GetItemProperties();
   PropertyDescriptor myPropertyDescriptor = 
   myPropertyDescriptors["Name"];
   Console.WriteLine(myPropertyDescriptor.Name);
   Console.WriteLine(myPropertyDescriptor.GetValue
   (dt.DefaultView[0]));
}
Private Sub ShowGetItemProperties()
   ' Create a new DataTable and add two columns.
   Dim dt As New DataTable()
   dt.Columns.Add("Name", Type.GetType("System.String"))
   dt.Columns.Add("ID", Type.GetType("System.String"))
   ' Add a row to the table.
   Dim dr As DataRow = dt.NewRow()
   dr("Name") = "Ann"
   dr("ID") = "AAA"
   dt.Rows.Add(dr)
     
   Dim myPropertyDescriptors As PropertyDescriptorCollection = _
   Me.BindingContext(dt).GetItemProperties()
   Dim myPropertyDescriptor As PropertyDescriptor = myPropertyDescriptors("Name")
   Console.WriteLine(myPropertyDescriptor.Name)
   Console.WriteLine(myPropertyDescriptor.GetValue(dt.DefaultView(0)))
End Sub

另請參閱

適用於

GetItemProperties(ArrayList, ArrayList)

使用指定的 ArrayList,取得繫結的屬性描述項集合。

protected public:
 virtual System::ComponentModel::PropertyDescriptorCollection ^ GetItemProperties(System::Collections::ArrayList ^ dataSources, System::Collections::ArrayList ^ listAccessors);
protected internal virtual System.ComponentModel.PropertyDescriptorCollection GetItemProperties (System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors);
protected internal virtual System.ComponentModel.PropertyDescriptorCollection? GetItemProperties (System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors);
abstract member GetItemProperties : System.Collections.ArrayList * System.Collections.ArrayList -> System.ComponentModel.PropertyDescriptorCollection
override this.GetItemProperties : System.Collections.ArrayList * System.Collections.ArrayList -> System.ComponentModel.PropertyDescriptorCollection
Protected Friend Overridable Function GetItemProperties (dataSources As ArrayList, listAccessors As ArrayList) As PropertyDescriptorCollection

參數

dataSources
ArrayList

包含資料來源的 ArrayList

listAccessors
ArrayList

ArrayList,包含資料表的繫結屬性。

傳回

PropertyDescriptorCollection

PropertyDescriptorCollection,表示繫結的屬性描述項。

備註

開發人員會使用此方法來建立資料繫結控制項。

另請參閱

適用於

GetItemProperties(Type, Int32, ArrayList, ArrayList)

取得由這個 BindingManagerBase 所管理項目的屬性清單。

protected:
 virtual System::ComponentModel::PropertyDescriptorCollection ^ GetItemProperties(Type ^ listType, int offset, System::Collections::ArrayList ^ dataSources, System::Collections::ArrayList ^ listAccessors);
protected virtual System.ComponentModel.PropertyDescriptorCollection GetItemProperties (Type listType, int offset, System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors);
protected virtual System.ComponentModel.PropertyDescriptorCollection? GetItemProperties (Type listType, int offset, System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors);
abstract member GetItemProperties : Type * int * System.Collections.ArrayList * System.Collections.ArrayList -> System.ComponentModel.PropertyDescriptorCollection
override this.GetItemProperties : Type * int * System.Collections.ArrayList * System.Collections.ArrayList -> System.ComponentModel.PropertyDescriptorCollection
Protected Overridable Function GetItemProperties (listType As Type, offset As Integer, dataSources As ArrayList, listAccessors As ArrayList) As PropertyDescriptorCollection

參數

listType
Type

繫結清單的 Type

offset
Int32

計數器,用來遞迴呼叫方法。

dataSources
ArrayList

包含資料來源的 ArrayList

listAccessors
ArrayList

ArrayList,包含資料表的繫結屬性。

傳回

PropertyDescriptorCollection

PropertyDescriptorCollection,表示繫結的屬性描述項。

範例

下列程式碼範例會 GetItemProperties 使用 方法傳回 PropertyDescriptorCollectionBindingManagerBase 。 然後,此範例會 Name 列印集合中每個 PropertyDescriptor 的 和 PropertyType

void PrintPropertyDescriptions( BindingManagerBase^ b )
{
   Console::WriteLine( "Printing Property Descriptions" );
   PropertyDescriptorCollection^ ps = b->GetItemProperties();
   for ( int i = 0; i < ps->Count; i++ )
   {
      Console::WriteLine( "\t{0}\t{1}", ps[ i ]->Name, ps[ i ]->PropertyType );

   }
}
private void PrintPropertyDescriptions(BindingManagerBase b)
{
   Console.WriteLine("Printing Property Descriptions");
   PropertyDescriptorCollection ps = b.GetItemProperties();
   for(int i = 0; i < ps.Count; i++)
   {
      Console.WriteLine("\t" + ps[i].Name + "\t" + ps[i].PropertyType);
   }
}
Private Sub PrintPropertyDescriptions(b As BindingManagerBase)
    Console.WriteLine("Printing Property Descriptions")
    Dim ps As PropertyDescriptorCollection = b.GetItemProperties()
    Dim i As Integer
    For i = 0 To ps.Count - 1
        Console.WriteLine((ControlChars.Tab & ps(i).Name & ControlChars.Tab & ps(i).PropertyType.ToString))
    Next i
End Sub

備註

開發人員會使用此多載來建立資料繫結控制項。

另請參閱

適用於