Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Di 03.04.07 14:37 
Hi,
ich hab eine Frage zu ComboBoxen: Wie kann man da Sachen hinzufügen (die sollen nicht mehr editierbar sein, man soll sie nur auswählen können). Kann man das irgendwie in den Delphi-code mit reinnehmen oder muss man das aus einer externen Datei lesen lassen?
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 03.04.07 14:44 
Hallo!

Stell um Objektsinspektor den Style deiner Combobox auf csDropDownList

Über Combobox.items.add('STRING') kannst du Sachen hinzufügen!

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Di 03.04.07 15:52 
Danke das geht jetz! =)
kann ich auch das was in den Combo Boxen eingestellt ist mit in meine Ini speichern?
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 03.04.07 16:40 
ja!

Falls du beim Softwarestart die gleichen Elemente in der Combobox hinterlegt hast wie beim Beenden der Software, dann ist es ausreichend wenn du den Itemindex speicherst und über

Combobox.Itemindex:= INI.ReadInteger('COMBO''Wert', -1);.

Sollte dies aber nicht der Fall sein, dann ist es besser du speicherst über Combobox.items.strings[Combobox.itemindex] den Text (String) ab und über combobox.items.add(INI.ReadString('COMBO''WERT''NULL') kannst ihn wieder laden!

Hoffe meine Erläuterungen sind hilfreich.

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Di 03.04.07 17:04 
irgendwie geht das nicht..bei save so
ausblenden Delphi-Quelltext
1:
Ini.WriteString('Bereich1','Schlüssel31',Combobox1.items.strings[Combobox1.itemindex]);					

und load so
ausblenden Delphi-Quelltext
1:
Combobox1.items.strings[Combobox1.itemindex]:=Ini.ReadString('Bereich1','Schlüssel31','Leer');					

ist doch falsch oder?
und bei dem was du gesagt hast speichert er nichts in die ini

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 03.04.07 17:25 
schnell getippt:

ausblenden 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:
uses inifiles;

var INI: TINIFile;

function schreibeINI: Boolean;
begin;
 //INIT
 schreibeINI:= false;
 try
  //Ini erzeugen
  INI:= TINIFile.create(extractfilepath(application.exename) + 'Konfig.INI');

  //Um den Inhalt zu speichern
  INI.writeString('Konfig''CBox1', CBbox1.items.strings[CBox1.itemindex]);
  //Um die Position zu speichern,
  INI.writeInteger('Konfig''CBox1', CBox1.itemindex);

  //INI wieder freigeben
  INI.free; 
  
  //Alles OK
  schreibeINI:= true;
 except
  on e: exception do
  begin
   messagebox(application.handle, pchar('Fehler beim Speichern: ' + #10#13#10#13 + e.message), 'Fehler', MB_IconERROR);
   exit;
  end;
 end;
end;


Laden:

ausblenden 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:
function ladeINI: Boolean;
begin;
 //Init
 ladeINI:= false;
 
 try
  //INIzugriff
  INI:= TINIfile.create(extractfilepath(application.handle) + 'Konfig.INI');
 
  //Wenn du den Wert gespeichert hast:
  CBox1.Items.add(INI.ReadString('Konfig''CBox1''<WERT>');
  //Wenn du die Position gespeichert hast:
  CBox1.itemindex:= INI.ReadInteger('Konfig''CBox1', -1);

  //INI freigeben
  INI.free
  //allesOK
  ladeINI:= true;
 except
  on e: exception do
  begin
   messagebox(application.handle, pchar('Fehler beim Laden: ' + #10#13#10#13 + e.message), 'Fehler', MB_IconERROR); 
   exit;
  end;
 end;
 
end;


LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Di 03.04.07 19:06 
danke, das klappt jetz auch!! :D