Autor Beitrag
Halunkel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Mo 29.05.06 22:21 
Hallo!

Ich würde gerne andere Objekte ausblenden, sobald ein Eintrag in einer Combobox ausgewählt wurde. Aber wie schaffe ich das ohne großen Quelltext??

Eine Möglichkeit wäre:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if combobox1.text = 'Eintrag1' then
  checkbox1.enabled := false;
if combobox1.text = 'Eintrag2' then
  checkbox1.enabled := false;
if combobox1.text = 'Eintrag3' then
  checkbox1.enabled := false;


Aber irgendwie ist die Lsg. blöd!

Gibts da ne schönere Lsg.??
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 29.05.06 22:24 
Moin!

Schau dir mal:
ausblenden Delphi-Quelltext
1:
ComboBox1.Items.IndexOf()					

an. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Mo 29.05.06 22:33 
ausblenden Delphi-Quelltext
1:
case combobox.itemindex of					

ist's da schon eher

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 29.05.06 22:35 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
case combobox1.itemindex of
 0 : checkbox1.enabled := false;
 1 : checkbox1.enabled := false;
 2 : checkbox1.enabled := false;


wenn immer das selbe ausgeführt werden soll:

ausblenden Delphi-Quelltext
1:
2:
case combobox1.itemindex of
 0,1,2 : checkbox1.enabled := false;


ob das geht weiß ich net musst du mal probieren:
ausblenden Delphi-Quelltext
1:
2:
case combobox1.itemindex of
 0..2 : checkbox1.enabled := false;


EDIT: da war ja jemand schneller
Halunkel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Mo 29.05.06 23:44 
Danke..

und wenn ich mehrere Checkboxen ausblenden möchte?

Die Caseformel funktioniert irgendwie nur, wenn ich nur Checkbox1 ausblende. Wie verknüpfe ich es?

Muss ich schreiben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
case combobox1.itemindex of
 0..17 :  Checkbox1.enabled := false;
case combobox1.itemindex of
 0..17 :  Checkbox2.enabled := false;
case combobox1.itemindex of
 0..17 :  Checkbox3.enabled := false;
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 29.05.06 23:48 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
case combobox1.itemindex of
 0..17 : begin
          Checkbox1.enabled := false;
          Checkbox2.enabled := false;
          Checkbox3.enabled := false;
         end;


bei dem bin ich mir nicht sicher obs geht musst du mal ausprobieren:
ausblenden Delphi-Quelltext
1:
2:
case combobox1.itemindex of
 0..17 : for i:=1 to 3 do Checkbox[i].enabled := false;
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 30.05.06 00:18 
Letzteres klappt natürlich NICHT, es sei denn CheckBox ist ein Array of TCheckBox. Aber klappen tut es so:
ausblenden Delphi-Quelltext
1:
2:
case combobox1.itemindex of   
 0..17 : for i:=1 to 3 do (FindComponent('CheckBox'+IntToStr(i)) as TCheckBox).enabled := false;

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Halunkel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 30.05.06 21:30 
Danke für eure Antworten!!
Nun würde ich gerne verschiedenen Einträgen verschieden Werte zuordnen und dann in einem Editfeld ausgeben.
Im richtigen Programm kommen noch viele andere WErte dazu, deshalb ist es wichtig den Wert in einer Variablen zu speichern. Aber leider funktioniert das hier nicht!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var a : double;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case comboBox1.ItemIndex of
0: a := 5;
1: a := 15;

Edit1.text := FloatToStr (a);
end;
[/user]
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 30



BeitragVerfasst: Di 30.05.06 21:32 
Versuchs mal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var a : double;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  case comboBox1.ItemIndex of
    0: a := 5;
    1: a := 15;
  end;
  Edit1.text := FloatToStr (a);
end;



:wave:
Halunkel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 30.05.06 21:45 
Perfekt!!

Vielen Dank das klappt!!