DataGridViewCellFormattingEventArgs.RowIndex 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 el índice de fila de la celda a la que se va a aplicar formato.
public:
property int RowIndex { int get(); };
public int RowIndex { get; }
member this.RowIndex : int
Public ReadOnly Property RowIndex As Integer
Valor de propiedad
Índice de fila de la celda a la que se va a aplicar formato.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar la RowIndex propiedad para recuperar la celda con formato. A continuación, se usa la referencia de celda para establecer el texto de información sobre herramientas de la celda.
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(Object^ /*sender*/,
DataGridViewCellFormattingEventArgs^ e)
{
if ( (e->ColumnIndex == this->dataGridView1->Columns["Rating"]->Index)
&& e->Value != nullptr )
{
DataGridViewCell^ cell =
this->dataGridView1->Rows[e->RowIndex]->Cells[e->ColumnIndex];
if (e->Value->Equals("*"))
{
cell->ToolTipText = "very bad";
}
else if (e->Value->Equals("**"))
{
cell->ToolTipText = "bad";
}
else if (e->Value->Equals("***"))
{
cell->ToolTipText = "good";
}
else if (e->Value->Equals("****"))
{
cell->ToolTipText = "very good";
}
}
}
// Sets the ToolTip text for cells in the Rating column.
void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index)
&& e.Value != null )
{
DataGridViewCell cell =
this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.Value.Equals("*"))
{
cell.ToolTipText = "very bad";
}
else if (e.Value.Equals("**"))
{
cell.ToolTipText = "bad";
}
else if (e.Value.Equals("***"))
{
cell.ToolTipText = "good";
}
else if (e.Value.Equals("****"))
{
cell.ToolTipText = "very good";
}
}
}
' Sets the ToolTip text for cells in the Rating column.
Sub dataGridView1_CellFormatting(ByVal sender As Object, _
ByVal e As DataGridViewCellFormattingEventArgs) _
Handles dataGridView1.CellFormatting
If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _
AndAlso (e.Value IsNot Nothing) Then
With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex)
If e.Value.Equals("*") Then
.ToolTipText = "very bad"
ElseIf e.Value.Equals("**") Then
.ToolTipText = "bad"
ElseIf e.Value.Equals("***") Then
.ToolTipText = "good"
ElseIf e.Value.Equals("****") Then
.ToolTipText = "very good"
End If
End With
End If
End Sub
Comentarios
Utilice la RowIndex propiedad para obtener un índice en la Rows propiedad de .DataGridView