全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1209
推到 Plurk!
推到 Facebook!

listbox 与 stringGrid 的运用

尚未結案
lhh
一般會員


發表:16
回覆:21
積分:7
註冊:2004-11-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-01-19 03:51:12 IP:81.154.xxx.xxx 未訂閱
假设listbox1 中有100个integer 0..99, stringGrid colCount =2, rowCount1=101, [1,1]..[1,101] 中有100个integer 也是0..99。 stringGrid1.heigh := 200 stringGrid1.Width := 200 请问有什么方法当我double click listbox中任何一个integer会在stringGrid中找到相对应的integer并且显示在200×200 的stringGrid中呢? Thanx so much!
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-01-19 08:16:24 IP:202.39.xxx.xxx 未訂閱
這樣嗎?
procedure TForm1.ListBox1.Click(Sender: TObject);
begin
  if ListBox1.ItemIndex <> -1 then
    StringGrid1.Cells[1, ListBox1.ItemIndex   1] := ListBox1.Items[ListBox1.ItemIndex];
end;
lhh
一般會員


發表:16
回覆:21
積分:7
註冊:2004-11-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-01-19 17:15:19 IP:213.106.xxx.xxx 未訂閱
This is only the frist step. what i want is when double click the items in listbox1, e.g. 56 and then the corresponding number 56 in the stringgrid's cell will be selected automatically and show in the 200* 200 dialog . thanx
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-01-19 19:29:41 IP:202.39.xxx.xxx 未訂閱
是這樣嗎(前面兩題)?
procedure TForm1.ListBox1.Click(Sender: TObject);
var
  sNo: string;
  iNo, iCol, iRow: integer;
begin
  iNo := ListBox1.ItemIndex;
  sNo := ListBox1.Items[ListBox1.ItemIndex];      stringGrid.Col := 1;
  stringGrid.Row := iNo   1;
end;
還有最後一點要顯示 200 x 200 的 StringGrid 是什麼意思? 顯示在 Cell 還是? 是有兩個 TStringGrid 嗎? 200 x 200 的 Dialog 是? -- 世界上為什麼會有貧窮?因為大部分人都不想和別人分享自己所擁有的 -- Mother Teresa
系統時間:2024-05-01 10:38:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!