有關查詢欄位清除問題 |
答題得分者是:chih
|
Fen
一般會員 發表:18 回覆:17 積分:7 註冊:2003-10-20 發送簡訊給我 |
|
chih
版主 發表:48 回覆:1186 積分:639 註冊:2002-04-02 發送簡訊給我 |
procedure TForm1.Button1Click(Sender: TObject); var j:integer; begin for j := 1 to Form1.ComponentCount - 1 do begin if (Components[j] is TComboBox) then begin (Components[j] as TComboBox).Items.Clear; (Components[j] as TComboBox).Text:=''; end; end; end;TRY TRY SEE 發表人 - chih 於 2003/11/18 15:48:46 |
Fen
一般會員 發表:18 回覆:17 積分:7 註冊:2003-10-20 發送簡訊給我 |
謝謝你,用你的方法在小小修改一下,此問題已經解決;
修改的原因是因為你的方法將欄位清空後,下一次要在查詢時,ComboBox的資料就沒有了,所以我在程式後面再加回原來的資料,如下: procedure TMainForm.btnclearClick(Sender: TObject);
begin
if (ComboBoxSeasonYear is TComboBox) then
begin
(ComboBoxSeasonYear as TComboBox).Items.Clear;
(ComboBoxSeasonYear as TComboBox).Text:=''; TableInquire.TableName := 'VW_SeasonYear';
TableInquire.Active := True;
while not TableInquire.eof do
begin
ComboBoxSeasonYear.Items.Add
(TableInquire.FieldValues['SeasonYear']);
TableInquire.Next;
end;
TableInquire.Active := False;
end; 不過程式跑起來,在按下清除時會變一個一個的消失,不知道我這樣寫是不是由何瑕疵?
|
chih
版主 發表:48 回覆:1186 積分:639 註冊:2002-04-02 發送簡訊給我 |
1.同時更新ComboBox的內容
procedure TMainForm.btnclearClick(Sender: TObject); var j: integer; begin for j := 1 to Form1.ComponentCount - 1 do begin if (Components[j] is TComboBox) then begin (Components[j] as TComboBox).Items.Clear; (Components[j] as TComboBox).Text := ''; end; TableInquire.TableName := 'VW_SeasonYear'; TableInquire.Active := True; while not TableInquire.eof do begin (Components[j] as TComboBox).Items.Add (TableInquire.FieldValues['SeasonYear']); TableInquire.Next; end; TableInquire.Active := False; end; end;2.只有清除User 選擇條件,不更新ComboBox的內容 procedure TMainForm.btnclearClick(Sender: TObject); var j: integer; begin for j := 1 to Form1.ComponentCount - 1 do begin if (Components[j] is TComboBox) then (Components[j] as TComboBox).Text := ''; end; end;TRY TRY SEE...^^ 發表人 - chih 於 2003/11/20 15:08:06 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |