Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   C# Mehrere TextBoxen "verketten" (https://www.delphipraxis.net/58536-mehrere-textboxen-verketten.html)

faux 8. Dez 2005 16:10


Mehrere TextBoxen "verketten"
 
Hallo!

Gibts in C# auch sowas ähnliches wie FindComponent unter Win32?
Was ich vor habe:

Ich habe auf einer Form mehere TextBoxen. Jede TextBox hat eine MaxLength zugewiesen bekommen. Wenn ich jetzt in eine TextBox was tippe und das Maximum erreiche, soll automatisch die nächste den Focus erhalten.
Umgekehrt will ich das auch machen: Wenn ich Backspace drücke, obwohl das Feld bereits leer ist, so soll das vorherige den Focus erhalten.
Das ganze soll dann so wie in meiner Passkontrolle aussehen.
Dort habe ich das so gelöst:

Delphi-Quellcode:
if (Length((Sender as TEdit).Text) = (Sender as TEdit).MaxLength) and ((Sender as TEdit).Tag < 11) then
begin
  a := (Sender as TEdit).Tag;
  repeat
    inc(a);
  until ((FindComponent('Edit'+IntToStr(a)) as TEdit).Enabled);
  (FindComponent('Edit'+IntToStr(a)) as TEdit).SetFocus;
end;
Hier hat jedes Edit übrigens als Tag die Nummer des Edits. Also Edit4 hat im Tag 4. So erspare ich mir einen Schritt.

Wäre nett, wenn mir wer eine Idee gibt.

Grüße
Faux


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz