日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ListBox combobox的常用功能

發(fā)布時(shí)間:2025/5/22 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ListBox combobox的常用功能 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

delphi TStringList 用法詳解

//TStringList 常用方法與屬性 :
var
? List: TStringList;
? i: Integer;
begin
? List := TStringList.Create;
? List.Add('Strings1');?????????? {添加}
? List.Add('Strings2');
? List.Exchange(0,1);???????????? {置換}
? List.Insert(0,'Strings3');????? {插入}
? i := List.IndexOf('Strings1');? {第一次出現(xiàn)的位置}
? List.Sort;????????????????????? {排序}
? List.Sorted := True; ? {指定排序}
? List.Count;???????????????????? {總數(shù)}
? List.Text;????????????????????? {文本集合}
? List.Delete(0);???????????????? {刪除, 0是第一個(gè)數(shù)據(jù)}
? List.LoadFromFile('c:/tmp.txt');{打開}
? List.SaveToFile('c:/tmp.txt');? {保存}
? List.Clear;???????????????????? {清空}
? List.Free;????????????????????? {釋放}
end;

combobox1.Items.Add(edit1.Text); //將編輯框內(nèi)容添加到combobox
edit1.Text:=combobox1.Items[0] ;

//對(duì)listbox中的整型數(shù)據(jù)重小到大排序
procedure sortfunc(ListBox:TListBox);
var
??I,J:Integer;
??temp:string;
begin
??with??ListBox??do
??begin
???for i:=0 to Count-1???do
????for j:=i to Count-1???do
??????if StrToInt(Items[i])>StrToInt(Items[j])???then
????????begin
??????????temp:=Items[i];
??????????Items[i]:=Items[j];
??????????Items[j]:=temp;
????????end;
??end;
end; listbox排序 1 sort {產(chǎn)生隨機(jī)數(shù)}
procedure?TForm1.Button1Click(Sender:?TObject);
var
??result:Integer;
??i:Integer;
begin
??ListBox1.Clear;
??for?i:=0?to?StrToInt(Edit1.Text)?do
??begin
??????Randomize;
??????Result:=Random(100)+1;
??????listbox1.Items.Add(IntToStr(result));
??end;
end;

{進(jìn)行排序}
procedure?TForm1.Button5Click(Sender:?TObject);
var
I,J:Integer;
temp:string;?{速度有慢}
begin
??with??ListBox1??do
??begin
???for?i:=0?to?Count-1???do
????for?j:=i?to?Count-1???do
??????if?StrToInt(Items[i])>StrToInt(Items[j])???then
????????begin
??????????temp:=Items[i];
??????????Items[i]:=Items[j];
??????????Items[j]:=temp;
????????end;
??end;
end; ? ? {添加Edit1.text}
???if ListBox1.Items.IndexOf(Edit1.Text)<0 then??ListBox1.Items.Add(Edit1.Text);
???Edit1.SetFocus;

{添加listbox1選中的那一項(xiàng)}
????listbox2.Items.Add(ListBox1.Items[listbox1.ItemIndex]);

{刪除選中的項(xiàng)目}
??ListBox2.Items.Delete(ListBox2.ItemIndex);
??ListBox2.DeleteSelected; //刪除選中的項(xiàng)目

{清空列表框}
ListBox1.Items.Clear;?
listbox2.Clear;

{全選}
??ListBox1.MultiSelect:=True;
??ListBox1.SelectAll;

{如何判斷 listbox中的內(nèi)容為空}
????if???listbox1.Items.Count=0??then??{ 為空};
{全部添加}
var
??i:Integer;
begin
??for i:=0 to ListBox1.Count-1 do
??begin
???ListBox2.Items.Add(listbox1.Items[i]);??//循環(huán)添加
??end;
end;

{使第1項(xiàng)被高亮選中}
????ListBox1.selected[0]:=True];//listbox1的選中項(xiàng)目

{listbox1的選中項(xiàng)目}
????Edit1.Text:=ListBox1.Items[ListBox1.ItemIndex];

{在第1行插入字符}
????ListBox1.Items.Insert(0,Edit1.Text); {先判斷后添加,不添加列表已存在的信息 } ?? if ListBox1.Items.IndexOf(Edit1.Text)<0 then? ListBox1.Items.Add(Edit1.Text); ?? if ComboBox1.Items.IndexOf(Edit1.Text)<0 then? ComboBox1.Items.Add(Edit1.Text); ? //listbox dragDrop DragOver
procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;

procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
(Sender as TEdit).Text := (Source as TListBox).Items[(Source as TListBox).ItemIndex];
end; ? // Edit Label配合ListBox

Label1.Caption := Listbox1.Items[Listbox1.ItemIndex];
Edit1.text := Listbox1.Items[Listbox1.ItemIndex]; ? ? ? //CheckListBox1常用屬性和方法事件 ? //列表成員的 序列說明 第1位 0 第2位 1 ... 第n位 n-1 不在成員類 -1 ? //在項(xiàng)目中添加字符串(子項(xiàng)目的最后一位接著添加) ????? CheckListBox1.Items.Add(edit1.Text); ? //全選 高亮選中Selected ???? CheckListBox1.MultiSelect := True; ???? CheckListBox1.SelectAll; ? //全選 Checked All procedure TForm1.Button11Click(Sender: TObject); var i :integer; begin ? for i := 0 to CheckListBox1.Items.Count - 1 do ??? begin ????? CheckListBox1.Checked[i] := True;//反選設(shè)置為False ??? end; end; ? //讓第n行被高亮選中 CheckListBox1.Selected[1]:=true;//第2行 ? //取消高亮選中 ? CheckListBox1.ClearSelection; ? //第3行的項(xiàng)目灰色不可用 CheckListBox1.ItemEnabled[2] := False;//True可用 ? //刪除高亮選中的項(xiàng)目,(只管高亮選中就會(huì)被刪除,和checked是否無關(guān)) ??????? CheckListBox1.DeleteSelected;//刪除選中項(xiàng)目,即使該給項(xiàng)目 沒勾上也會(huì)被刪除 ? //刪除已勾選的中項(xiàng)目 procedure TForm1.Button5Click(Sender: TObject); var i : integer; begin for i := CheckListBox1.Items.Count-1 downto 0 do //從后面往前面刪 ?? begin ?? if CheckListBox1.Checked[i] then ????? begin ???????? CheckListBox1.Items.Delete(i); ????? end; ?? end; end; ? //清空項(xiàng)目 ? CheckListBox1.Items.Clear; ? //將CheckListBox1的全部添加到CheckListBox2的Items中 ? procedure TForm1.Button1Click(Sender: TObject); var i:Integer; begin CheckListBox2.Items.Clear; for i := CheckListBox1.Items.Count - 1 downto 0 do ?? begin ????? CheckListBox2.Items.Add(CheckListBox1.Items[i]); ?? end; end; ? //CheckListBox1的items操作,如單擊CheckListBox1第1項(xiàng)彈出消息??? ? //items的拖拽調(diào)換items的位置??? //改變選中行的背景顏色??? //CheckListBox1信息 讀取 和寫入 ? ?

來自為知筆記(Wiz)

轉(zhuǎn)載于:https://www.cnblogs.com/xe2011/archive/2012/05/26/2518892.html

總結(jié)

以上是生活随笔為你收集整理的ListBox combobox的常用功能的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。