DataGrid.CurrentRowIndex Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o índice da linha que atualmente tem o foco.
public:
property int CurrentRowIndex { int get(); void set(int value); };
[System.ComponentModel.Browsable(false)]
public int CurrentRowIndex { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentRowIndex : int with get, set
Public Property CurrentRowIndex As Integer
Valor de Propriedade
O índice baseado em zero da linha atual.
- Atributos
Exceções
Não existe CurrencyManager.
Exemplos
O exemplo de código seguinte devolve o CurrentRowIndex.
private:
void GetSelectedIndex( DataGrid^ myGrid )
{
Console::WriteLine( myGrid->CurrentRowIndex );
}
void SetSelectedIndex( DataGrid^ myGrid, int selIndex )
{
myGrid->CurrentRowIndex = selIndex;
}
private void GetSelectedIndex(DataGrid myGrid){
Console.WriteLine(myGrid.CurrentRowIndex);
}
private void SetSelectedIndex(DataGrid myGrid, int selIndex){
myGrid.CurrentRowIndex = selIndex;
}
Private Sub GetSelectedIndex(ByVal myGrid As DataGrid)
Console.WriteLine(myGrid.CurrentRowIndex)
End Sub
Private Sub SetSelectedIndex(ByVal myGrid As DataGrid, ByVal selIndex As Integer)
myGrid.CurrentRowIndex= selIndex
End Sub
Observações
Definir a CurrentRowIndex propriedade para um valor diferente do seu valor atual faz o controlo rolar para que a linha especificada fique à vista.
A CurrentRowIndex propriedade permite-lhe iterar pelas linhas de uma tabela mãe mesmo que esteja a visualizar as linhas da tabela filha. Por exemplo, se estiver a visualizar uma tabela filha, incrementar o CurrentRowIndex fará com que o System.Windows.Forms.DataGrid mostre o próximo conjunto de registos na tabela filho que estão ligados à tabela principal.
Se o utilizador estiver a visualizar uma tabela pai, ou uma tabela sem relações com filhos, então a propriedade devolve o índice baseado em zero da linha atual.