1
我有一個組合框,我在下面的代碼如何對組合框內的項目進行排序?
combobox1.Items.BeginUpdate;
try
combobox1.Sorted := True;
combobox1.Items.Add('0');
combobox1.Items.Add('2');
combobox1.Items.Add('1');
combobox1.Items.Add('3');
combobox1.Items.Add('5');
combobox1.Items.Add('4');
finally
combobox1.Items.EndUpdate;
end;
我想這些數字爲0,1,2,3,4,5排序......等一些號碼添加到一樣,在combobox
內。
我啓用了Sorted屬性,但項目沒有排序。
我該如何對combobox
內的數字進行分類?
我加載combobox
物品從使用的TList這段代碼:
var
J : integer;
themes : Tthemes;
begin
ComboBox1.Items.BeginUpdate;
try
ComboBox1.Sorted := True;
for J := 0 to listitems.Count - 1 do
begin
themes := listitems.Items[J];
ComboBox1.Items.Add(themes.designid);
end;
finally
ComboBox1.Items.EndUpdate;
end;
ComboBox1.ItemIndex := 0;
我想你的代碼和結果進行排序! XE7並假設Vcl項目。 –
奇怪我做同樣的代碼,結果來了,因爲他們添加沒有排序IAM使用此代碼在DLL項目 –
我無法想象如何項目是一個DLL可以有任何影響。但爲了以防萬一,請嘗試使用新的vcl表單項目。放下窗體上的組合框和一個按鈕。在按鈕OnClick事件複製 - 粘貼上面的代碼。沒有其他設計時間設置。 –