次の方法で共有


DataRowView.Item プロパティ (String)

指定した列の値を取得または設定します。

[C#] C# では、このプロパティは DataRowView クラスのインデクサになります。

Overloads Public Default Property Item( _
   ByVal property As String _) As Object
[C#]
public object this[stringproperty] {get; set;}
[C++]
public: __property Object* get_Item(String* property);public: __property void set_Item(String* property,   Object*);
[JScript]
returnValue = DataRowViewObject.Item(property);DataRowViewObject.Item(property) = returnValue;またはreturnValue = DataRowViewObject(property);DataRowViewObject(property) = returnValue;

[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。

引数 [JScript]

  • property
    指定した列を格納している文字列。

パラメータ [Visual Basic, C#, C++]

  • property
    指定した列を格納している文字列。

プロパティ値

列の値。

使用例

[Visual Basic, C#, C++] DataView の変更された各行内の列の値にテキストを追加する例を次に示します。

 
Private Sub SetDataRowView()
    Dim dv As DataView = CType(dataGrid1.DataSource, DataView)
    ' Set the filter to display only those rows that were modified.
    dv.RowStateFilter = DataViewRowState.ModifiedCurrent
    ' Change the value of the CompanyName column for each modified row.
    Dim drv As DataRowView
    For Each drv In  dv
        drv("CompanyName") = drv("CompanyName").ToString() + " new value"
    Next drv
End Sub

[C#] 
private void SetDataRowView(){
   DataView dv = (DataView) dataGrid1.DataSource;
   // Set the filter to display only those rows that were modified.
   dv.RowStateFilter=DataViewRowState.ModifiedCurrent;
   // Change the value of the CompanyName column for each modified row.
   foreach(DataRowView drv in dv){
      drv["CompanyName"] += " new value";
   }
}

[C++] 
private:
 void SetDataRowView(){
    DataView* dv = dynamic_cast<DataView*> (dataGrid1->DataSource);
    // Set the filter to display only those rows that were modified.
    dv->RowStateFilter=DataViewRowState::ModifiedCurrent;
    // Change the value of the CompanyName column for each modified row.
    System::Collections::IEnumerator* myEnum = dv->GetEnumerator();
    while (myEnum->MoveNext())
    {
       DataRowView* drv = __try_cast<DataRowView*>(myEnum->Current);
       drv->Item[S"CompanyName"] = String::Concat( drv->Item[S"CompanyName"], S" new value" );
    }
 }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataRowView クラス | DataRowView メンバ | System.Data 名前空間 | DataRowView.Item オーバーロードの一覧