![]() |
Problem mit ComboBox
Hallo
Ich habe ein Problem mit ComboBox! In den String hab ich in der ersten Zeile 1 in der zweiten Zeile 2 und in der dritten 3. Hier ist der Ouelltext für den Button:
Delphi-Quellcode:
Aber bei 1 ziegt er nichts an nicht an bei 2 zeigt er 1 an und bei 3 zeigt er 2 an.
begin
case ComboBox1.ItemIndex of 1 : Label1.Caption := '1'; 2 : Label1.Caption := '2'; 3 : Label1.Caption := '3'; end; end; Imprenziep alles verschoben. Kan mir jemand helfen? Gruß Landfloh |
Re: Problem mit ComboBox
Der ItemIndex ist 0-basiert, d.h. der erste Eintrag hat den Index 0.
|
Re: Problem mit ComboBox
Der erste Eintrag hat den Index 0
|
Re: Problem mit ComboBox
Zitat:
|
Re: Problem mit ComboBox
Zitat:
|
Re: Problem mit ComboBox
Was muss man denn dann in den ItemIndex schreiben? :wiejetzt:
|
Re: Problem mit ComboBox
Delphi-Quellcode:
case ComboBox1.ItemIndex of
0 : Label1.Caption := '1'; 1 : Label1.Caption := '2'; 2 : Label1.Caption := '3'; end; |
Re: Problem mit ComboBox
Danke funktioniert jetzt.
|
Re: Problem mit ComboBox
Eine Frage noch wenn ich will das Label1 nur dann anzeibt wenn ComboBox1 und ComboBox2 auf 1 stehen wie mach ich es denn dann? :?:
|
Re: Problem mit ComboBox
Wie, auf 1 stehen? ItemIndex oder Text?
|
Re: Problem mit ComboBox
Label1.Visible
|
Re: Problem mit ComboBox
Zitat:
|
Re: Problem mit ComboBox
Delphi-Quellcode:
Label1.Visible := (ComboBox1.ItemIndex = 1) and (ComboBox2.ItemIndex = 1);
|
Re: Problem mit ComboBox
Und wenn man das jetzt in den Ouelltext einbauen würde? :wiejetzt:
|
Re: Problem mit ComboBox
Einfach nach dem Case
|
Re: Problem mit ComboBox
Dann kommt das [Fehler] Unit1.pas(32): Konstantenausdruck erwartet
|
Re: Problem mit ComboBox
Delphi-Quellcode:
begin
case ComboBox1.ItemIndex of 0 : Label1.Caption := '1'; 1 : begin Label1.Visible := ComboBox2.ItemIndex = 1; //man könnte hier auch noch vorher auf visible abfragen Label1.Caption := '2'; end; 2 : Label1.Caption := '3'; end; end; |
Re: Problem mit ComboBox
Wenn ich ComboBox1 auf 1 stelle und ComboBox2 auf 2 dann zeigt er trozdem 1 an.
Ich möchte aber das er nur 1 anzeigt wenn beide ComBoxen auf 1 stehen. |
Re: Problem mit ComboBox
Du hast eigentlich alles was du brauchst. Du musst also nur den Code an die gewünschten Bedingungen anpassen
|
Re: Problem mit ComboBox
Was ich gepostet habe, war die Ereignisbehandlung von ComboBox1. Es sollte nicht allzu schwierig sein, das auch auf ComboBox2 zu übertragen, oder? :stupid:
|
Re: Problem mit ComboBox
Zitat:
Hab einfach nur nich logisch nachgedacht. :wall: Jetzt leuft es auf jeden Fall. :xmas: Danke an alle! :bounce1: :bouncing4: :firejump: |
DP-Maintenance
Dieses Thema wurde von "Phoenix" von "Programmieren allgemein" nach "VCL / WinForms / Controls" verschoben.
Geht um ne Komponente... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz