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

StringGrid.width 與StringGrid.colWidths的問題

尚未結案
furesu
一般會員


發表:26
回覆:10
積分:7
註冊:2004-10-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-09-12 17:16:40 IP:61.62.xxx.xxx 未訂閱
在設計碰到一個問題的....  Form create時候設StringGrid.width:=300; 假設動態加入3個colunm 每個寬度為100 |---------| |-----|-----|-----| 3個colunm 想要做到說 當前2個colunm寬總合>300時,第3個colunm隱藏, 並把第2個colunm寬自動調整到剛好300, 然後當前2個colunm寬總合未到300,第3個colunm顯示, 設寬度為300-(前2colunm個寬總合) StringGrid的FixedCol=0 , RowCount=2
    j:=0;
  for i:=0 to 2 do begin
    if (j>=300) then begin
      StringGrid1.colWidths[i]:=-1;
      StringGrid1.Cells[i,1] := IntToStr(StringGrid1.colWidths[i]);
    end else if j<300 then begin
      StringGrid1.Cells[i,1] := IntToStr(StringGrid1.colWidths[i]);
      j:=j StringGrid1.colWidths[i];
    end;
    //j:=j StringGrid1.colWidths[i];
  end;
變成說可以隱藏,不過最後一個colunm寬度上不會自動調整....腦筋打結了.
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-09-12 18:11:39 IP:210.65.xxx.xxx 未訂閱
Hi furesu,
var
  W : Integer;
begin
  W := StringGrid1.ColWidths[0]   StringGrid1.ColWidths[1];
  if W > 300 then
    begin
      StringGrid1.ColWidths[1] := 300;
      StringGrid1.ColWidths[2] := 0;
    end
  else
    begin
      StringGrid1.ColWidths[2] := 300 - W;
    end;
end;
---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman
系統時間:2024-05-19 12:27:49
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!