如何用dbedit的text去刪掉combobox內的item |
答題得分者是:hagar
|
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
|
danny
版主 發表:100 回覆:522 積分:595 註冊:2002-03-11 發送簡訊給我 |
引言:有點混哦 ! 問題也沒有說清楚. 我猜您可能 ComboBox1 在 Design Time 時已經有一些內定值了. 所以在 OnFormCreate 及 OnButtonClick 中要呼叫以下 procedure引言:抱歉我試一些方法都沒有用 有沒有更詳細的說明?引言: 在系統未結束前是刪了 但再進入時還是會存在 有沒有能真的刪掉的方法?那跟你問如何動態增加 Item 的那篇一樣 參照 ccchen 前輩的說法來做. procedure TForm1.DeleteComboBoxItem; var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); end;
------
將問題盡快結案也是一種禮貌! |
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
[/quote] 有點混哦 ! 問題也沒有說清楚. 我猜您可能 ComboBox1 在 Design Time 時已經有一些內定值了.
所以在 OnFormCreate 及 OnButtonClick 中要呼叫以下 procedure
procedure TForm1.DeleteComboBoxItem; var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); end;[/quote] 我不太曉得應如何宣告及呼叫 procedure Tform1.deletecomboboxItem; 所以我直接在form1的oncreate及button1的onclick 都打入以下程式碼 var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); 但在TForm1.formcreate(sender:Tobject); 執行有錯誤訊息出現->(~89****) 能否詳述如何宣告及呼叫 procedure Tform1.deletecomboboxItem; aric |
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
假設將 ComboBox1 的 Items 存在 C:\ComboBox1Item.Txt
1.在 FormCreate 做載入 Item 的動作
procedure TForm1.FormCreate(Sender: TObject); begin if FileExists('C:\ComboBox1Item.Txt') then ComboBox1.Items.LoadFromFile('C:\ComboBox1Item.Txt'); end;2.Button1 做比對 DBEdit1.Text 來刪除 Item 的動作: procedure TForm1.Button1Click(Sender: TObject); var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); end;3.在 FormClose 的時候, 將 ComboBox1 的 Item 存入 C:\ComboBox1Item.Txt procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ComboBox1.Items.SaveToFile('C:\ComboBox1Item.Txt'); end;--- Have you ever wondered what it would be like? |
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
引言: 假設將 ComboBox1 的 Items 存在 C:\ComboBox1Item.Txt 1.在 FormCreate 做載入 Item 的動作有了滿意的答覆真是謝謝大家 aricprocedure TForm1.FormCreate(Sender: TObject); begin if FileExists('C:\ComboBox1Item.Txt') then ComboBox1.Items.LoadFromFile('C:\ComboBox1Item.Txt'); end;2.Button1 做比對 DBEdit1.Text 來刪除 Item 的動作:procedure TForm1.Button1Click(Sender: TObject); var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); end;3.在 FormClose 的時候, 將 ComboBox1 的 Item 存入 C:\ComboBox1Item.Txtprocedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ComboBox1.Items.SaveToFile('C:\ComboBox1Item.Txt'); end;--- Have you ever wondered what it would be like? |
huangeider
高階會員 發表:288 回覆:492 積分:231 註冊:2003-02-26 發送簡訊給我 |
引言: 假設將 ComboBox1 的 Items 存在 C:\ComboBox1Item.Txt 1.在 FormCreate 做載入 Item 的動作有了滿意的答覆真是謝謝大家 aric 發表人 - huangeider 於 2003/03/20 14:42:20procedure TForm1.FormCreate(Sender: TObject); begin if FileExists('C:\ComboBox1Item.Txt') then ComboBox1.Items.LoadFromFile('C:\ComboBox1Item.Txt'); end;2.Button1 做比對 DBEdit1.Text 來刪除 Item 的動作:procedure TForm1.Button1Click(Sender: TObject); var idx: integer; begin idx := ComboBox1.Items.IndexOf(DBEdit1.Text); if idx <> -1 then ComboBox1.Items.Delete(idx); end;3.在 FormClose 的時候, 將 ComboBox1 的 Item 存入 C:\ComboBox1Item.Txtprocedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ComboBox1.Items.SaveToFile('C:\ComboBox1Item.Txt'); end;--- Have you ever wondered what it would be like? |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |