DataRowView.Item[] Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece un valor en una columna especificada.
Sobrecargas
| Nombre | Description |
|---|---|
| Item[Int32] |
Obtiene o establece un valor en una columna especificada. |
| Item[String] |
Obtiene o establece un valor en una columna especificada. |
Item[Int32]
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
Obtiene o establece un valor en una columna especificada.
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
Parámetros
- ndx
- Int32
Índice de columna.
Valor de propiedad
Valor de la columna.
Excepciones
DataView no permite modificaciones y DataRowView no es nueva.
Ninguna columna corresponde a ese valor de índice.
Ejemplos
En el ejemplo siguiente se muestra el valor de cada elemento de cada DataRowView en un 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
Se aplica a
Item[String]
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
- Source:
- DataRowView.cs
Obtiene o establece un valor en una columna especificada.
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
Parámetros
- property
- String
Cadena que contiene la columna especificada.
Valor de propiedad
Valor de la columna.
Excepciones
No se encontró una columna con el nombre o la relación especificados.
O bien
DataView no permite modificaciones y DataRowView no es nueva.
No coincide property al establecer un valor.
Ejemplos
En el ejemplo siguiente se anexa texto al valor de una columna de cada fila modificada de .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