DataRowView.Item[] Property

Definition

Získá nebo nastaví hodnotu v zadaném sloupci.Gets or sets a value in a specified column.

Overloads

Item[Int32]

Získá nebo nastaví hodnotu v zadaném sloupci.Gets or sets a value in a specified column.

Item[String]

Získá nebo nastaví hodnotu v zadaném sloupci.Gets or sets a value in a specified column.

Item[Int32]

Získá nebo nastaví hodnotu v zadaném sloupci.Gets or sets a value in a specified column.

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, set
Default Public Property Item(ndx As Integer) As Object

Parameters

ndx
Int32

Index sloupceThe column index.

Property Value

Object

Hodnota sloupceThe value of the column.

Exceptions

DataView nepovoluje úpravy a DataRowView není nového.The DataView doesn't allow edits and DataRowView is not new.

K této hodnotě indexu neodpovídají žádné sloupce.No column corresponds to that index value.

Examples

Následující příklad zobrazí hodnotu v každé položce každého DataRowView v DataView.The following example displays the value in each item of each DataRowView in a DataView.

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]

Získá nebo nastaví hodnotu v zadaném sloupci.Gets or sets a value in a specified column.

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, set
Default Public Property Item(property As String) As Object

Parameters

property
String

Řetězec, který obsahuje zadaný sloupec.String that contains the specified column.

Property Value

Object

Hodnota sloupceThe value of the column.

Exceptions

Sloupec se zadaným názvem nebo vztahem nebyl nalezen.A column with the specified name or relation was not found.

-nebo--or-

DataView nepovoluje úpravy a DataRowView není nového.The DataView doesn't allow edits and DataRowView is not new.

Při nastavování hodnoty se neshoduje property.Unmatched property when setting a value.

Examples

Následující příklad připojí text k hodnotě sloupce v každém upravovaném řádku DataView.The following example appends text to the value of a column in each modified row of a 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

Applies to