Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
DataGridViewCell..::.Value Property

Gets or sets the value associated with this cell.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic
<BrowsableAttribute(False)> _
Public Property Value As Object
    Get
    Set
C#
[BrowsableAttribute(false)]
public Object Value { get; set; }
Visual C++
[BrowsableAttribute(false)]
public:
property Object^ Value {
    Object^ get ();
    void set (Object^ value);
}
F#
[<BrowsableAttribute(false)>]
member Value : Object with get, set

Property Value

Type: System..::.Object
Gets or sets the data to be displayed by the cell. The default is nullNothingnullptra null reference (Nothing in Visual Basic).
ExceptionCondition
ArgumentOutOfRangeException

RowIndex is outside the valid range of 0 to the number of rows in the control minus 1.

InvalidOperationException

ColumnIndex is less than 0, indicating that the cell is a row header cell.

When you assign a different value to a cell, the CellValueChanged event of the DataGridView control is raised.

The Value property is the actual data object contained by the cell, whereas the FormattedValue property is the formatted representation of the data. The ValueType and FormattedValueType properties correspond to the data types of these values, respectively.

When you set the Value property, the specified value is not automatically converted from a formatted, display value to an underlying cell value. For example, the DataGridViewCellStyle in effect for the cell is ignored, so setting Value to DataGridViewCellStyle..::.NullValue does not result in a property value of DataGridViewCellStyle..::.DataSourceNullValue.

The following code example shows how to update a cell's contents with the Value property. This example is part of a larger code example provided in How to: Manipulate Rows in the Windows Forms DataGridView Control.

Visual Basic
' Give cheescake excellent rating.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button8.Click

    UpdateStars(dataGridView.Rows(4), "******************")
End Sub

Private ratingColumn As Integer = 3

Private Sub UpdateStars(ByVal row As DataGridViewRow, _
    ByVal stars As String)

    row.Cells(ratingColumn).Value = stars

    ' Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, _
        DataGridViewAutoSizeColumnMode.DisplayedCells)

End Sub
C#
// Give cheescake excellent rating.
private void Button8_Click(object sender,
    System.EventArgs e)
{
    UpdateStars(dataGridView.Rows[4], "******************");
}

int ratingColumn = 3;

private void UpdateStars(DataGridViewRow row, string stars)
{

    row.Cells[ratingColumn].Value = stars;

    // Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, 
        DataGridViewAutoSizeColumnMode.DisplayedCells);
}
Visual C++
   // Give cheescake excellent rating.
   void Button8_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      UpdateStars( dataGridView->Rows[ 4 ], L"******************" );
   }

   int ratingColumn;
   void UpdateStars( DataGridViewRow^ row, String^ stars )
   {
      row->Cells[ ratingColumn ]->Value = stars;

      // Resize the column width to account for the new value.
      row->DataGridView->AutoResizeColumn( ratingColumn, DataGridViewAutoSizeColumnMode::DisplayedCells );
   }


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Biblioteca de clases de .NET Framework
DataGridViewCell..::.Value (Propiedad)

Obtiene o establece el valor asociado a esta celda.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Visual Basic
<BrowsableAttribute(False)> _
Public Property Value As Object
    Get
    Set
C#
[BrowsableAttribute(false)]
public Object Value { get; set; }
Visual C++
[BrowsableAttribute(false)]
public:
property Object^ Value {
    Object^ get ();
    void set (Object^ value);
}
F#
[<BrowsableAttribute(false)>]
member Value : Object with get, set

Valor de propiedad

Tipo: System..::.Object
Obtiene o establece los datos que va a mostrar la celda. El valor predeterminado es nullNothingnullptrreferencia null (Nothing en Visual Basic).
ExcepciónCondición
ArgumentOutOfRangeException

RowIndex está fuera del intervalo válido, que va desde 0 hasta el número de filas del control menos 1.

InvalidOperationException

ColumnIndex es menor que 0, lo que indica que la celda es una celda de encabezado de fila.

Cuando se asigna un valor distinto de la celda, se provoca el evento CellValueChanged del control DataGridView.

La propiedad Value es el objeto de datos real que contiene la celda, mientras que la propiedad FormattedValue es la representación con formato de los datos. Las propiedades ValueType y FormattedValueType corresponden a los tipos de datos de estos valores, respectivamente.

Cuando establece la propiedad Value, el valor especificado no se convierte automáticamente de un valor mostrado con formato en un valor de celda subyacente. Por ejemplo, se omite DataGridViewCellStyle vigente para la celda, por tanto, establecer Value en DataGridViewCellStyle..::.NullValue no da como resultado un valor de propiedad DataGridViewCellStyle..::.DataSourceNullValue.

En el ejemplo de código siguiente se muestra cómo actualizar el contenido de una celda con la propiedad Value. Este ejemplo forma parte de un ejemplo de código más extenso que se proporciona en Cómo: Manipular filas en el control DataGridView de formularios Windows Forms.

Visual Basic
' Give cheescake excellent rating.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button8.Click

    UpdateStars(dataGridView.Rows(4), "******************")
End Sub

Private ratingColumn As Integer = 3

Private Sub UpdateStars(ByVal row As DataGridViewRow, _
    ByVal stars As String)

    row.Cells(ratingColumn).Value = stars

    ' Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, _
        DataGridViewAutoSizeColumnMode.DisplayedCells)

End Sub
C#
// Give cheescake excellent rating.
private void Button8_Click(object sender,
    System.EventArgs e)
{
    UpdateStars(dataGridView.Rows[4], "******************");
}

int ratingColumn = 3;

private void UpdateStars(DataGridViewRow row, string stars)
{

    row.Cells[ratingColumn].Value = stars;

    // Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, 
        DataGridViewAutoSizeColumnMode.DisplayedCells);
}
Visual C++
   // Give cheescake excellent rating.
   void Button8_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      UpdateStars( dataGridView->Rows[ 4 ], L"******************" );
   }

   int ratingColumn;
   void UpdateStars( DataGridViewRow^ row, String^ stars )
   {
      row->Cells[ ratingColumn ]->Value = stars;

      // Resize the column width to account for the new value.
      row->DataGridView->AutoResizeColumn( ratingColumn, DataGridViewAutoSizeColumnMode::DisplayedCells );
   }


.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker