Autor Beitrag
Airtrox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Mi 09.12.09 18:15 
Hallo,

ich habe wieder mal ein kleines Problem:
Ich habe eine Combobox(Listbox) mit 4 Auswahlmöglichkeiten. Darunter sind 2 edit Feld. Weiterhin habe ich schon 8 Variablen definiert, je eine für einen Combobox.itemindex wert. Ich möchte nun, dass jedes mal wenn etwa anderes gewählt wird, auch der Inhalt der passenden Variable in die edit Felder geschrieben wird:

Mein Versuch war so:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
procedure TForm2.Edit1Change(Sender: TObject);
begin
  case combobox1.itemindex of
  0 : begin
        var11 := edit1.Text;
        var12 := edit2.Text;
      end;
  1 : begin
        var21 := edit1.Text;
        var22 := edit2.Text;
      end;
  2 : begin
        var31 := edit1.Text;
        var32 := edit2.Text;
      end;
  3 : begin
        var41 := edit1.Text;
        var42 := edit2.Text;
      end;
  end;
end;

procedure TForm2.ComboBox1Change(Sender: TObject);
begin
  trim(edit1.text);

  case combobox1.itemindex of
  0 : begin
        edit1.Text := var11;
        edit2.text := var12;
      end;
  1 : begin
        edit1.Text := var21;
        edit2.text := var22;
      end;
  2 : begin
        edit1.Text := var31;
        edit2.text := var32;
      end;
  3 : begin
        edit1.Text := var41;
        edit2.text := var42;
      end;
  end;
end;

(Die Variablen wurden am Anfang definiert (alles strings)

So, das klappt auch mit edit1. Bei edit2 ändert sich jedoch nichts (Passwortchar ist *)


wundert mich ehrlich gesagt, warum es beim 2. edit feld nicht klappt. Wisst ihr vllt warum?


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Sa 12.12.2009 um 12:33
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Mi 09.12.09 21:20 
Könntest Du uns denn vielleicht auch mal erklären, was genau Du damit vorhast?
- Ich würde ja normalerweise ein und der selben Variable unterschiedliche Werte je nach Fall zuordnen.
Und ist denn nur Dein zweites Edit-Feld ein Sternchen-(also Passwort-)Feld?
Wenn ja, wie siehst Du dann, was da überhaupt steht?
- Oder meinst Du die Länge verändert sich nicht?

Edit: Ach so, Du meinst also, wenn Du in Dein zweites Edit-Feld was schreibst?
Dem zweiten Edit-Feld hast Du dann wohl nur noch nicht die Methode zugewiesen...
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Mi 09.12.09 22:21 
Ich habe mal das Passwortchar wieder zurückgesetzt und der einmal eingegeben Wert (egal für welchen itemindex) bleibt bei Änderung der Liste gleich.

Was meinst du mit nicht der Methode zugewisen? edit2 bekommt die selben Befehle wie edit1 (siehe quelltext)
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 13:13 
weiß keiner eine Antwort :(
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 11.12.09 13:26 
Schau mal bei Edit2 in die Ereignisse, ob da das OnChange auch zugewiesen ist.

_________________
PROGRAMMER: A device for converting coffee into software.
Airtrox Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 109


Delphi 7
BeitragVerfasst: Fr 11.12.09 14:03 
Danke Xentar, daran lag es wirklich :oops:
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 11.12.09 14:10 
Das war es auch, was ffgorcky oben mit seinem Edit meinte ;) Dank also nicht mir.

_________________
PROGRAMMER: A device for converting coffee into software.