DataRowView.Item[] 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置指定列中的值。
重载
| Item[Int32] | 获取或设置指定列中的值。 | 
| Item[String] | 获取或设置指定列中的值。 | 
Item[Int32]
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
获取或设置指定列中的值。
public:
 property System::Object ^ default[int] { System::Object ^ get(int ndx); void set(int ndx, System::Object ^ value); };public object this[int ndx] { get; set; }member this.Item(int) : obj with get, setDefault Public Property Item(ndx As Integer) As Object参数
- ndx
- Int32
列索引。
属性值
列的值。
例外
DataView 不允许编辑,DataRowView 不是新项。
任何列都不与该索引值相对应。
示例
以下示例显示 中每个项DataRowViewDataView中的值。
private static void WriteViewRows(DataView view)
{
    int colCount = view.Table.Columns.Count;
    // Iterate through the rows of the DataView.
    foreach (DataRowView rowView in view)
    {
        // Display the value in each item of the DataRowView
        for (int i = 0; i < colCount; i++)
            Console.Write(rowView[i] + "\table");
        Console.WriteLine();
    }
}
Private Shared Sub WriteViewRows(view As DataView)
   Dim colCount As Integer = view.Table.Columns.Count
   ' Iterate through the rows of the DataView.
   For Each rowView As DataRowView In view
     ' Display the value in each item of the DataRowView
     For i As Integer = 0 To colCount - 1
        Console.Write(rowView(i) & vbTab)
     Next
     Console.WriteLine()
   Next
End Sub
适用于
Item[String]
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
获取或设置指定列中的值。
public:
 property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ property); void set(System::String ^ property, System::Object ^ value); };public object this[string property] { get; set; }member this.Item(string) : obj with get, setDefault Public Property Item(property As String) As Object参数
- property
- String
包含指定列的字符串。
属性值
列的值。
例外
设置值时,property 不匹配。
示例
以下示例将文本追加到 的每个修改行 DataView中的列的值。
private void SetDataRowView()
{
    DataView view = (DataView) dataGrid1.DataSource;
    // Set the filter to display only those rows that were modified.
    view.RowStateFilter=DataViewRowState.ModifiedCurrent;
    // Change the value of the CompanyName column for each modified row.
    foreach(DataRowView rowView in view)
    {
        rowView["CompanyName"] += " new value";
    }
}
Private Sub SetDataRowView()
     Dim view As DataView = CType(dataGrid1.DataSource, DataView)
     ' Set the filter to display only those rows that were modified.
     view.RowStateFilter = DataViewRowState.ModifiedCurrent
     ' Change the value of the CompanyName column for each modified row.
     Dim rowView As DataRowView
     For Each rowView In  view
         rowView.Item("CompanyName") = _
         rowView.Item("CompanyName").ToString() & " new value"
     Next rowView
End Sub