Code: Alles auswählen
sl.Duplicates := dupIgnore;
Oder muss ich den Umweg über eine temporäre StringList machen, um die Doppelten Einträge zu entfernen ?
Code: Alles auswählen
sl.Duplicates := dupIgnore;
Code: Alles auswählen
constructor TCustomComboBox.Create(TheOwner : TComponent);
begin
inherited Create(TheOwner);
...
FItems := TStringlist.Create;
...
Code: Alles auswählen
TStringList(Combobox1.Items).AllowDuplicate := dupIgnore;
Code: Alles auswählen
procedure TForm1.FormCreate(Sender: TObject);
begin
// ComboBox1.Sorted := True;
TStringList(ComboBox1.Items).Sorted := True;
TStringList(ComboBox1.Items).Duplicates := dupIgnore;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ComboBox1.Items.Add('123');
end;
Code: Alles auswählen
procedure TForm1.Button1Click(Sender: TObject);
begin
TWin32ComboBoxStringList(ComboBox1.Items).Sorted := True; // dieser Cast geht
TStringList(ComboBox1.Items).Duplicates := dupIgnore; // dieser geht nicht
ComboBox1.Items.Add('123');
end;
Code: Alles auswählen
type
TLiveSelection = (lsMoney, lsChilds, lsTime);
TLive = Array[0..1] of TLiveSelection;
Code: Alles auswählen
if ComboBox1.Items.IndexOf('123') < 0 then ComboBox1.Items.Add('123');
Code: Alles auswählen
procedure TForm1.Button7Click(Sender: TObject);
var
sdd: TSelectDirectoryDialog;
ini: TIniFile;
i: integer;
sl: TStringList;
const
INIKey='tut_pfad';
begin
ComboBox1.Clear;
ini := TIniFile.Create(ConfigINIDatei);
sl := TStringList.Create;
ini.ReadSection(INIKey, sl);
for i := 0 to sl.Count - 1 do begin
ComboBox1.Items.Add(ini.ReadString(INIKey, sl[i], ''));
end;
sl.Free;
sdd := TSelectDirectoryDialog.Create(Self);
if sdd.Execute then begin
i:=ComboBox1.Items.IndexOf(sdd.FileName);
if i >= 0 then begin
ComboBox1.Items.Delete(i);
end;
ComboBox1.Items.Insert(0, sdd.FileName);
ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(sdd.FileName);
end;
sdd.Free;
for i := 0 to ComboBox1.Items.Count - 1 do begin
ini.WriteString(INIKey, IntToStr(i), ComboBox1.Items[i]);
end;
ini.Free;
end;
Code: Alles auswählen
procedure TSerial_Monitor_Form.Button_SendClick(Sender: TObject);
var
i: integer;
s: string;
begin
s := ComboBox_Send_Text.Text;
if Length(s) > 0 then begin
SerWrite(SerialHandle, s[1], Length(s));
i := ComboBox_Send_Text.Items.IndexOf(s);
if i >= 0 then begin
ComboBox_Send_Text.Items.Delete(i);
end;
ComboBox_Send_Text.Items.Insert(0, s);
ComboBox_Send_Text.Text := s;
end;
end;