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
DataGridViewRow Class

Represents a row in a DataGridView control.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic
Public Class DataGridViewRow _
    Inherits DataGridViewBand
C#
public class DataGridViewRow : DataGridViewBand
Visual C++
public ref class DataGridViewRow : public DataGridViewBand
F#
type DataGridViewRow =  
    class
        inherit DataGridViewBand
    end

The DataGridViewRow type exposes the following members.

  NameDescription
Public methodDataGridViewRowInitializes a new instance of the DataGridViewRow class without using a template.
Top
  NameDescription
Public propertyAccessibilityObjectGets the DataGridViewRow..::.DataGridViewRowAccessibleObject assigned to the DataGridViewRow.
Public propertyCellsGets the collection of cells that populate the row.
Public propertyContextMenuStripGets or sets the shortcut menu for the row. (Overrides DataGridViewBand..::.ContextMenuStrip.)
Public propertyDataBoundItemGets the data-bound object that populated the row.
Public propertyDataGridViewGets the DataGridView control associated with this element. (Inherited from DataGridViewElement.)
Public propertyDefaultCellStyleGets or sets the default styles for the row, which are used to render cells in the row unless the styles are overridden. (Overrides DataGridViewBand..::.DefaultCellStyle.)
Public propertyDefaultHeaderCellTypeGets or sets the run-time type of the default header cell. (Inherited from DataGridViewBand.)
Public propertyDisplayedGets a value indicating whether this row is displayed on the screen. (Overrides DataGridViewBand..::.Displayed.)
Public propertyDividerHeightGets or sets the height, in pixels, of the row divider.
Public propertyErrorTextGets or sets the error message text for row-level errors.
Public propertyFrozenGets or sets a value indicating whether the row is frozen. (Overrides DataGridViewBand..::.Frozen.)
Public propertyHasDefaultCellStyleGets a value indicating whether the DefaultCellStyle property has been set. (Inherited from DataGridViewBand.)
Public propertyHeaderCellGets or sets the row's header cell.
Protected propertyHeaderCellCoreGets or sets the header cell of the DataGridViewBand. (Inherited from DataGridViewBand.)
Public propertyHeightGets or sets the current height of the row.
Public propertyIndexGets the relative position of the band within the DataGridView control. (Inherited from DataGridViewBand.)
Public propertyInheritedStyleGets the cell style in effect for the row. (Overrides DataGridViewBand..::.InheritedStyle.)
Public propertyIsNewRowGets a value indicating whether the row is the row for new records.
Protected propertyIsRowGets a value indicating whether the band represents a row. (Inherited from DataGridViewBand.)
Public propertyMinimumHeightGets or sets the minimum height of the row.
Public propertyReadOnlyGets or sets a value indicating whether the row is read-only. (Overrides DataGridViewBand..::.ReadOnly.)
Public propertyResizableGets or sets a value indicating whether users can resize the row or indicating that the behavior is inherited from the DataGridView..::.AllowUserToResizeRows property. (Overrides DataGridViewBand..::.Resizable.)
Public propertySelectedGets or sets a value indicating whether the row is selected. (Overrides DataGridViewBand..::.Selected.)
Public propertyStateGets the current state of the row. (Overrides DataGridViewElement..::.State.)
Public propertyTagGets or sets the object that contains data to associate with the band. (Inherited from DataGridViewBand.)
Public propertyVisibleGets or sets a value indicating whether the row is visible. (Overrides DataGridViewBand..::.Visible.)
Top
  NameDescription
Public methodAdjustRowHeaderBorderStyleModifies an input row header border style according to the specified criteria.
Public methodCloneCreates an exact copy of this row. (Overrides DataGridViewBand..::.Clone()()().)
Protected methodCreateAccessibilityInstanceCreates a new accessible object for the DataGridViewRow.
Public methodCreateCells(DataGridView)Clears the existing cells and sets their template according to the supplied DataGridView template.
Public methodCreateCells(DataGridView, array<Object>[]()[])Clears the existing cells and sets their template and values.
Protected methodCreateCellsInstanceConstructs a new collection of cells based on this row.
Public methodDispose()()()Releases all resources used by the DataGridViewBand. (Inherited from DataGridViewBand.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the DataGridViewBand and optionally releases the managed resources. (Inherited from DataGridViewBand.)
Protected methodDrawFocusDraws a focus rectangle around the specified bounds.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeReleases the resources associated with the band. (Inherited from DataGridViewBand.)
Public methodGetContextMenuStripGets the shortcut menu for the row.
Public methodGetErrorTextGets the error text for the row at the specified index.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetPreferredHeightCalculates the ideal height of the specified row based on the specified criteria.
Public methodGetStateReturns a value indicating the current state of the row.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnDataGridViewChangedCalled when the band is associated with a different DataGridView. (Inherited from DataGridViewBand.)
Protected methodPaintPaints the current row.
Protected methodPaintCellsPaints the cells in the current row.
Protected methodPaintHeaderPaints the header cell of the current row.
Protected methodRaiseCellClickRaises the DataGridView..::.CellClick event. (Inherited from DataGridViewElement.)
Protected methodRaiseCellContentClickRaises the DataGridView..::.CellContentClick event. (Inherited from DataGridViewElement.)
Protected methodRaiseCellContentDoubleClickRaises the DataGridView..::.CellContentDoubleClick event. (Inherited from DataGridViewElement.)
Protected methodRaiseCellValueChangedRaises the DataGridView..::.CellValueChanged event. (Inherited from DataGridViewElement.)
Protected methodRaiseDataErrorRaises the DataGridView..::.DataError event. (Inherited from DataGridViewElement.)
Protected methodRaiseMouseWheelRaises the Control..::.MouseWheel event. (Inherited from DataGridViewElement.)
Public methodSetValuesSets the values of the row's cells.
Public methodToStringGets a human-readable string that describes the row. (Overrides DataGridViewBand..::.ToString()()().)
Top

The DataGridViewRow class represents a row in a DataGridView control. You can retrieve rows through the Rows and SelectedRows collections of the control.

Unlike a DataGridViewColumn, a DataGridViewRow physically contains a collection of all of the cells in that row. You can access this collection through the Cells property.

The DataGridViewRow class is used to access the individual cell elements, as well as to adjust the appearance and behavior of the row user interface (UI), such as height and cell style. Typically, you will want all rows or most rows in the control to share the same characteristics. To set cell styles for all rows in the control, set the properties of the object returned by the DataGridView..::.RowsDefaultCellStyle property. To set styles for alternating rows, use the DataGridView..::.AlternatingRowsDefaultCellStyle property. For more information about cell styles, see Cell Styles in the Windows Forms DataGridView Control. You can also use the DataGridView..::.RowTemplate property to define a row that will be used as a basis for all rows added to the control.

The DataGridView control will share DataGridViewRow objects across multiple data rows whenever possible to avoid performance penalties. Unless you are working with large amounts of data and experiencing performance issues, you can typically ignore row sharing. A shared row is indicated by an Index property value of -1. Some members of the DataGridViewRow class cannot be used with shared rows, but you can unshare a row by accessing it through the DataGridViewRowCollection..::.Item property. Rows can also become unshared in other ways. To access a row without unsharing it, use the DataGridViewRowCollection..::.SharedRow method. When working with large amounts of data, you should be aware of how rows are shared and unshared to avoid performance penalties. For more information, see Best Practices for Scaling the Windows Forms DataGridView Control.

Notes to Inheritors

When you derive from DataGridViewRow and add new properties to the derived class, be sure to override the Clone method to copy the new properties during cloning operations. You should also call the base class's Clone method so that the properties of the base class are copied to the new cell.

The following code example illustrates the use of this type. This example is part of a larger example available in How to: Manipulate Rows in the Windows Forms DataGridView Control.

Visual Basic
' Set row labels.
Private Sub Button6_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button6.Click

    Dim rowNumber As Integer = 1
    For Each row As DataGridViewRow In dataGridView.Rows
        If row.IsNewRow Then Continue For
        row.HeaderCell.Value = "Row " & rowNumber
        rowNumber = rowNumber + 1
    Next
    dataGridView.AutoResizeRowHeadersWidth( _
        DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)
End Sub
C#
// Set row labels.
private void Button6_Click(object sender, System.EventArgs e)
{

    int rowNumber = 1;
    foreach (DataGridViewRow row in dataGridView.Rows)
    {
        if (row.IsNewRow) continue;
        row.HeaderCell.Value = "Row " + rowNumber;
        rowNumber = rowNumber + 1;
    }
    dataGridView.AutoResizeRowHeadersWidth(
        DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
Visual C++
   // Set row labels.
   void Button6_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {

      int rowNumber = 1;
      System::Collections::IEnumerator^ myEnum = safe_cast<System::Collections::IEnumerable^>(dataGridView->Rows)->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         DataGridViewRow^ row = safe_cast<DataGridViewRow^>(myEnum->Current);
         if ( row->IsNewRow )
                  continue;
         row->HeaderCell->Value = String::Format( L"Row {0}", rowNumber );

         rowNumber = rowNumber + 1;
      }

      dataGridView->AutoResizeRowHeadersWidth( DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders );
   }


.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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
DataGridViewRow (Clase)

Representa una fila de un control DataGridView.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Visual Basic
Public Class DataGridViewRow _
    Inherits DataGridViewBand
C#
public class DataGridViewRow : DataGridViewBand
Visual C++
public ref class DataGridViewRow : public DataGridViewBand
F#
type DataGridViewRow =  
    class
        inherit DataGridViewBand
    end

El tipo DataGridViewRow expone los siguientes miembros.

  NombreDescripción
Método públicoDataGridViewRowInicializa una nueva instancia de la clase DataGridViewRow sin utilizar una plantilla.
Arriba
  NombreDescripción
Propiedad públicaAccessibilityObjectObtiene el objeto DataGridViewRow..::.DataGridViewRowAccessibleObject asignado a DataGridViewRow.
Propiedad públicaCellsObtiene la colección de celdas que rellenan la fila.
Propiedad públicaContextMenuStripObtiene o establece el menú contextual para la fila. (Invalida a DataGridViewBand..::.ContextMenuStrip).
Propiedad públicaDataBoundItemObtiene el objeto enlazado a datos que ha rellenado la fila.
Propiedad públicaDataGridViewObtiene el control DataGridView asociado a este elemento. (Se hereda de DataGridViewElement).
Propiedad públicaDefaultCellStyleObtiene o establece los estilos predeterminados para la fila, que se utilizan para representar las celdas de la fila a menos que se reemplacen los estilos. (Invalida a DataGridViewBand..::.DefaultCellStyle).
Propiedad públicaDefaultHeaderCellTypeObtiene o establece el tipo de la celda de encabezado predeterminada en tiempo de ejecución. (Se hereda de DataGridViewBand).
Propiedad públicaDisplayedObtiene un valor que indica si esta fila se muestra en la pantalla. (Invalida a DataGridViewBand..::.Displayed).
Propiedad públicaDividerHeightObtiene o establece el alto, en píxeles, del divisor de fila.
Propiedad públicaErrorTextObtiene o establece el texto del mensaje de error para los errores de fila.
Propiedad públicaFrozenObtiene o establece un valor que indica si la fila está inmovilizada. (Invalida a DataGridViewBand..::.Frozen).
Propiedad públicaHasDefaultCellStyleObtiene un valor que indica si la propiedad DefaultCellStyle se ha establecido. (Se hereda de DataGridViewBand).
Propiedad públicaHeaderCellObtiene o establece la celda de encabezado de la fila.
Propiedad protegidaHeaderCellCoreObtiene o establece la celda de encabezado de DataGridViewBand. (Se hereda de DataGridViewBand).
Propiedad públicaHeightObtiene o establece el alto actual de la fila.
Propiedad públicaIndexObtiene la posición relativa de la banda dentro del control DataGridView. (Se hereda de DataGridViewBand).
Propiedad públicaInheritedStyleObtiene el estilo de celda en vigor para la fila. (Invalida a DataGridViewBand..::.InheritedStyle).
Propiedad públicaIsNewRowObtiene un valor que indica si la fila es la fila de nuevos registros.
Propiedad protegidaIsRowObtiene un valor que indica si la banda representa una fila. (Se hereda de DataGridViewBand).
Propiedad públicaMinimumHeightObtiene o establece el alto mínimo de la fila.
Propiedad públicaReadOnlyObtiene o establece un valor que indica si la fila es de sólo lectura. (Invalida a DataGridViewBand..::.ReadOnly).
Propiedad públicaResizableObtiene o establece un valor que indica si los usuarios pueden cambiar el tamaño de la fila o si el comportamiento se hereda de la propiedad DataGridView..::.AllowUserToResizeRows. (Invalida a DataGridViewBand..::.Resizable).
Propiedad públicaSelectedObtiene o establece un valor que indica si la fila está seleccionada. (Invalida a DataGridViewBand..::.Selected).
Propiedad públicaStateObtiene el estado actual de la fila. (Invalida a DataGridViewElement..::.State).
Propiedad públicaTagObtiene o establece el objeto que contiene datos para asociar a la banda. (Se hereda de DataGridViewBand).
Propiedad públicaVisibleObtiene o establece un valor que indica si la fila es visible. (Invalida a DataGridViewBand..::.Visible).
Arriba
  NombreDescripción
Método públicoAdjustRowHeaderBorderStyleModifica un estilo de borde de encabezado de fila de entrada según los criterios especificados.
Método públicoCloneCrea una copia exacta de esta fila. (Invalida a DataGridViewBand..::.Clone()()()).
Método protegidoCreateAccessibilityInstanceCrea un nuevo objeto accesible para la fila DataGridViewRow.
Método públicoCreateCells(DataGridView)Borra las celdas existentes y establece su plantilla según la plantilla DataGridView proporcionada.
Método públicoCreateCells(DataGridView, array<Object>[]()[])Borra las celdas existentes y establece su plantilla y valores.
Método protegidoCreateCellsInstanceConstruye una nueva colección de celdas basada en esta fila.
Método públicoDispose()()()Libera todos los recursos utilizados por DataGridViewBand. (Se hereda de DataGridViewBand).
Método protegidoDispose(Boolean)Libera los recursos no administrados que utiliza el objeto DataGridViewBand y, opcionalmente, los recursos administrados. (Se hereda de DataGridViewBand).
Método protegidoDrawFocusDibuja un rectángulo de foco alrededor de los límites especificados.
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizeLibera los recursos asociados a la banda. (Se hereda de DataGridViewBand).
Método públicoGetContextMenuStripObtiene el menú contextual para la fila.
Método públicoGetErrorTextObtiene el texto de error para la fila del índice especificado.
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetPreferredHeightCalcula el alto ideal de la fila que se indica basándose en los criterios especificados.
Método públicoGetStateDevuelve un valor que indica el estado actual de la fila.
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método protegidoMemberwiseCloneCrea una copia superficial del objeto Object actual. (Se hereda de Object).
Método protegidoOnDataGridViewChangedSe llama cuando la banda está asociada a un DataGridView diferente. (Se hereda de DataGridViewBand).
Método protegidoPaintDibuja la fila actual.
Método protegidoPaintCellsDibuja las celdas de la fila actual.
Método protegidoPaintHeaderDibuja el encabezado de celda de la fila actual.
Método protegidoRaiseCellClickProvoca el evento DataGridView..::.CellClick. (Se hereda de DataGridViewElement).
Método protegidoRaiseCellContentClickGenera el evento DataGridView..::.CellContentClick. (Se hereda de DataGridViewElement).
Método protegidoRaiseCellContentDoubleClickGenera el evento DataGridView..::.CellContentDoubleClick. (Se hereda de DataGridViewElement).
Método protegidoRaiseCellValueChangedGenera el evento DataGridView..::.CellValueChanged. (Se hereda de DataGridViewElement).
Método protegidoRaiseDataErrorGenera el evento DataGridView..::.DataError. (Se hereda de DataGridViewElement).
Método protegidoRaiseMouseWheelProvoca el evento Control..::.MouseWheel. (Se hereda de DataGridViewElement).
Método públicoSetValuesEstablece los valores de las celdas de la fila.
Método públicoToStringObtiene una cadena inteligible que describe la fila. (Invalida a DataGridViewBand..::.ToString()()()).
Arriba

La clase DataGridViewRow representa una fila de un control DataGridView. Puede recuperar filas a través de las colecciones de Rows y SelectedRows del control.

A diferencia de DataGridViewColumn, DataGridViewRow contiene físicamente una colección de todas las celdas de esa fila. Se puede obtener acceso a esta colección mediante la propiedad Cells.

La clase DataGridViewRow se utiliza para obtener acceso a cada elemento de celda, así como para ajustar la apariencia y el comportamiento de la interfaz de usuario (UI) de la fila, como el alto y el estilo de celda. Normalmente, le interesará que todas las filas del control, o la mayoría de ellas, compartan las mismas características. Para establecer los estilos de celda para todas las filas del control, establezca las propiedades del objeto que devuelve la propiedad DataGridView..::.RowsDefaultCellStyle. Para establecer los estilos de las filas alternas, utilice la propiedad DataGridView..::.AlternatingRowsDefaultCellStyle. Para obtener más información sobre los estilos de celda, vea Estilos de celda en el control DataGridView de formularios Windows Forms También se puede utilizar la propiedad DataGridView..::.RowTemplate para definir una fila que sirva de base para todas las filas que se agreguen al control.

Para evitar reducciones del rendimiento y siempre que sea posible, el control DataGridView compartirá objetos DataGridViewRow por varias filas de datos. Por lo común podrá omitir el uso compartido de filas, salvo cuando esté trabajando con cantidades grandes de datos y experimente problemas de rendimiento. Una fila compartida viene indicada por un valor -1 en la propiedad Index. Algunos miembros de la clase DataGridViewRow no se pueden utilizar con filas compartidas, pero se puede hacer que una fila deje de estar compartida obteniendo acceso a ella a través de la propiedad DataGridViewRowCollection..::.Item. También hay otras formas de hacer que las filas dejen de estar compartidas. Para obtener acceso a una fila sin que deje de estar compartida, utilice el método DataGridViewRowCollection..::.SharedRow. Cuando trabaje con grandes cantidades de datos, tenga presente cómo están compartidas o no las filas para evitar reducciones del rendimiento. Para obtener más información, vea Procedimientos recomendados para ajustar la escala del control DataGridView en formularios Windows Forms.

Notas para los herederos

Cuando derive de DataGridViewRow y agregue nuevas propiedades a la clase derivada, asegúrese de reemplazar el método Clone para copiar las nuevas propiedades durante las operaciones de clonación. También debe llamar al método Clone de la clase base para que las propiedades de la clase base se copien en la nueva celda.

En el ejemplo de código siguiente se muestra el uso de este tipo. Este ejemplo forma parte de un ejemplo más extenso proporcionado en Cómo: Manipular filas en el control DataGridView de formularios Windows Forms.

Visual Basic
' Set row labels.
Private Sub Button6_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button6.Click

    Dim rowNumber As Integer = 1
    For Each row As DataGridViewRow In dataGridView.Rows
        If row.IsNewRow Then Continue For
        row.HeaderCell.Value = "Row " & rowNumber
        rowNumber = rowNumber + 1
    Next
    dataGridView.AutoResizeRowHeadersWidth( _
        DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders)
End Sub
C#
// Set row labels.
private void Button6_Click(object sender, System.EventArgs e)
{

    int rowNumber = 1;
    foreach (DataGridViewRow row in dataGridView.Rows)
    {
        if (row.IsNewRow) continue;
        row.HeaderCell.Value = "Row " + rowNumber;
        rowNumber = rowNumber + 1;
    }
    dataGridView.AutoResizeRowHeadersWidth(
        DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
}
Visual C++
   // Set row labels.
   void Button6_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {

      int rowNumber = 1;
      System::Collections::IEnumerator^ myEnum = safe_cast<System::Collections::IEnumerable^>(dataGridView->Rows)->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         DataGridViewRow^ row = safe_cast<DataGridViewRow^>(myEnum->Current);
         if ( row->IsNewRow )
                  continue;
         row->HeaderCell->Value = String::Format( L"Row {0}", rowNumber );

         rowNumber = rowNumber + 1;
      }

      dataGridView->AutoResizeRowHeadersWidth( DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders );
   }


.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.
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
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