Autor Beitrag
GericasS
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Di 22.01.08 19:56 
Morgen Jungs,

ich hab folgenden Code

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  if ComboBox1.Text = 'Quadrat' then
  Label1.Caption := 'Seite a' ;
  Label2.Caption := 'Seite a' ;
  if ComboBox1.Text = 'Rechteck' then
  Label1.Caption := 'Seite a' ;
  Label2.Caption := 'Seite b' ;
  if ComboBox1.Text = 'Dreieck' then
  Label1.Caption := 'Seite g' ;
  Label2.Caption := 'Seite h' ;


diesen habe ich in das OnChange der ComboBox gesetzt !

Wenn ich nun aber z.B in der ComboBox Quadrat auswähle, kommt es dazu das Label2 immer "h" bekommt ! Wo liegt da der Fehler ?
Auch wenn ich anschließen Rechteck angebe bleibt es bei "h" !!


grüße GericasS

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 22.01.08 19:59 
Um mehrere Vorgänge mit einer if-Bedingung zu verknüpfen, musst du sie in begin und end fassen.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Di 22.01.08 20:02 
Danke erstmal werds versuchen !

edit : Funktioniert super danke ! :D

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Di 22.01.08 21:10 
Ein kleiner Tipp:

Stelle die Eingenschaft Style deiner Combobox auf csDropDownList, und ändere deinen Code folgendermaßen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
case ComboBox1.ItemIndex of
  0: // Quadrat
  begin
    Label1.Caption := 'Seite a' ;
    Label2.Caption := 'Seite a' ;
  end;
  1: // Rechteck
  begin
    Label1.Caption := 'Seite a' ;
    Label2.Caption := 'Seite b' ;
  end;
  2: // Dreieck
  begin
    Label1.Caption := 'Seite g' ;
    Label2.Caption := 'Seite h' ;
  end;
end;

Der User kann nur noch ein Element auswählen, das schon in der Liste steht. Du wolltest doch sicher nicht, dass man selber einen Wert eingeben kann!?. Außerdem kannst du so schneller neue Elemente hinzufügen.
GericasS Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 540

Windows Vista Home Premium
D2010, VisualStudio2008
BeitragVerfasst: Mi 23.01.08 08:05 
@Yogu :

Hey danke für den Tipp, das hatte ich schon gemacht, habe es nur nicht mit in den ersten Post geschrieben :D

_________________
Alexander N.
Neue Bewaffnung Amilo xi2428 T9300