CurrencyManager.Position Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá nebo nastaví pozici, na které jste v seznamu.
public:
virtual property int Position { int get(); void set(int value); };
public override int Position { get; set; }
member this.Position : int with get, set
Public Overrides Property Position As Integer
Hodnota vlastnosti
Číslo mezi 0 a Count mínusem 1.
Příklady
Následující příklady kódu používají Position vlastnost k povolení navigace v seznamu.
private:
void MoveNext( CurrencyManager^ myCurrencyManager )
{
if ( myCurrencyManager->Count == 0 )
{
Console::WriteLine( "No records to move to." );
return;
}
if ( myCurrencyManager->Position == myCurrencyManager->Count - 1 )
{
Console::WriteLine( "You're at end of the records" );
}
else
{
myCurrencyManager->Position += 1;
}
}
void MoveFirst( CurrencyManager^ myCurrencyManager )
{
if ( myCurrencyManager->Count == 0 )
{
Console::WriteLine( "No records to move to." );
return;
}
myCurrencyManager->Position = 0;
}
void MovePrevious( CurrencyManager^ myCurrencyManager )
{
if ( myCurrencyManager->Count == 0 )
{
Console::WriteLine( "No records to move to." );
return;
}
if ( myCurrencyManager->Position == 0 )
{
Console::WriteLine( "You're at the beginning of the records." );
}
else
{
myCurrencyManager->Position -= 1;
}
}
void MoveLast( CurrencyManager^ myCurrencyManager )
{
if ( myCurrencyManager->Count == 0 )
{
Console::WriteLine( "No records to move to." );
return;
}
myCurrencyManager->Position = myCurrencyManager->Count - 1;
}
private void MoveNext(CurrencyManager myCurrencyManager){
if(myCurrencyManager.Count == 0) {
Console.WriteLine("No records to move to.");
return;
}
if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
Console.WriteLine("You're at end of the records");
}
else{
myCurrencyManager.Position += 1;
}
}
private void MoveFirst(CurrencyManager myCurrencyManager){
if(myCurrencyManager.Count == 0) {
Console.WriteLine("No records to move to.");
return;
}
myCurrencyManager.Position = 0;
}
private void MovePrevious(CurrencyManager myCurrencyManager){
if(myCurrencyManager.Count == 0) {
Console.WriteLine("No records to move to.");
return;
}
if(myCurrencyManager.Position == 0) {
Console.WriteLine("You're at the beginning of the records.");
}
else{
myCurrencyManager.Position -= 1;
}
}
private void MoveLast(CurrencyManager myCurrencyManager){
if(myCurrencyManager.Count == 0) {
Console.WriteLine("No records to move to.");
return;
}
myCurrencyManager.Position = myCurrencyManager.Count - 1;
}
Private Sub MoveNext(ByVal myCurrencyManager As CurrencyManager)
If myCurrencyManager.Count = 0 Then
Console.WriteLine("No records to move to.")
Exit Sub
End If
If myCurrencyManager.Position = myCurrencyManager.Count - 1 Then
MessageBox.Show("You're at end of the records")
Else
myCurrencyManager.Position += 1
End If
End Sub
Private Sub MoveFirst(ByVal myCurrencyManager As CurrencyManager)
If myCurrencyManager.Count = 0 Then
Console.WriteLine("No records to move to.")
Exit Sub
End If
myCurrencyManager.Position = 0
End Sub
Private Sub MovePrevious(ByVal myCurrencyManager As CurrencyManager)
If myCurrencyManager.Count = 0 Then
Console.WriteLine("No records to move to.")
Exit Sub
End If
If myCurrencyManager.Position = 0 Then
MessageBox.Show("You're at the beginning of the records.")
Else
myCurrencyManager.Position -= 1
End if
End Sub
Private Sub MoveLast(ByVal myCurrencyManager As CurrencyManager)
If myCurrencyManager.Count = 0 Then
Console.WriteLine("No records to move to.")
Exit Sub
End If
myCurrencyManager.Position = myCurrencyManager.Count - 1
End Sub
Poznámky
Důležitou vlastností CurrencyManager třídy je Position vlastnost. V seznamu položek můžete zobrazit jenom jednu položku z celého seznamu. Pokud chcete určit, která položka se zobrazí, nastavte Position hodnotu na číslo v rozmezí od 0 (začátek seznamu) do Count minus 1 (konec seznamu).
Position Proto určuje měnu nebo místo v seznamu všech ovládacích prvků svázaných se stejným CurrencyManager. Představte si například seznam skládající se ze dvou sloupců s názvem Jméno a Příjmení. Dva TextBox ovládací prvky jsou svázané se stejným seznamem; první ovládací prvek je svázán s prvním sloupcem a druhý ovládací prvek je svázán s druhým sloupcem. Position Pokud je společné CurrencyManager nastaveno na třetí pozici, oba ovládací prvky zobrazí příslušné hodnoty pro danou pozici v seznamu. Jinými slovy, pokud se položka na pozici tři skládá z křestního jména "John" a příjmení "Smith", vázané ovládací prvky zobrazí "John" a "Smith".