請問ValueListEditor可否增加cols |
尚未結案
|
Angi
一般會員 發表:16 回覆:56 積分:14 註冊:2005-01-12 發送簡訊給我 |
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi Angi, 建議如下列討論所言,改用 TStringGrid 或是 TListView http://delphi.ktop.com.tw/topic.php?topic_id=54675 ----------------------------------
小弟才疏學淺,若有謬誤尚請不吝指教
----------------------------------
------
Fishman |
eko
一般會員 發表:21 回覆:36 積分:11 註冊:2004-09-26 發送簡訊給我 |
引言: Hi Angi, 建議如下列討論所言,改用 TStringGrid 或是 TListView http://delphi.ktop.com.tw/topic.php?topic_id=54675 ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ---------------------------------- >>< face="Verdana, Arial, Helvetica"> 用stringgrid來做的話 請問如何設定第一欄 是唯讀? 另外單行和雙行 如何實作讓他不同顏色 方便閱覽呢?Thanks |
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi All, 1.設定 StringGrid 的 FixedCols 為 1,第一欄將無法編輯 2.請參考
http://delphi.ktop.com.tw/topic.php?topic_id=63042
http://delphi.ktop.com.tw/topic.php?topic_id=63716
在 StringGrid 的 OnDrawCell 事件上加入以下程式碼
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var Obj : TstringGrid; BK_Color,Font_Color : TColor; begin Obj := TStringGrid(Sender); if (ACol > Obj.FixedCols -1 ) and (ARow > Obj.FixedRows - 1) then begin if not ((gdSelected in State) or (gdFocused in State)) then begin if ACol mod 2 = 0 then begin BK_Color := clMoneyGreen; Font_Color := clWindowText; end else begin BK_Color := clCream; Font_Color := clWindowText; end; Obj.Canvas.Brush.Color := BK_Color; Obj.Brush.Style := bsSolid; Obj.Font.Color := Font_Color; Obj.Canvas.FillRect(Rect); Obj.Canvas.TextOut(Rect.Left 2,Rect.Top 2,Obj.Cells[ACol,ARow]); end; end; end;---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman |
Angi
一般會員 發表:16 回覆:56 積分:14 註冊:2005-01-12 發送簡訊給我 |
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi Angi, 兩種方法
1.在 OnSelectCell 事件加入以下程式碼,讓 user 無法 Select 第四 Column
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin if ACol = 3 then // 3 代表第四 column CanSelect := False; end2.在 OnKeyPress 事件加入以下程式碼,讓 user 無法編輯第四 Column procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char); begin if TStringGrid(Sender).Col = 3 then // 3 代表第四 column key := #0; end;但是,此兩種方式還是無法避免由程式中編輯,僅能限制前端使用者編輯 ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman |
Angi
一般會員 發表:16 回覆:56 積分:14 註冊:2005-01-12 發送簡訊給我 |
|
Angi
一般會員 發表:16 回覆:56 積分:14 註冊:2005-01-12 發送簡訊給我 |
再問一下
如果在元件一開始
想把游標預設在第三欄第二列,有辦法嗎??
因為發現用
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
if ACol = 3 then // 3 代表第四 column
CanSelect := False;
end
而系統預設在第一欄第二列會失效...
也就是原來預設的那格,就是我不想提供輸入的欄位了
剛進去第一次若去改預設的那個欄位
上面的程式就控制不到了
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
|
Angi
一般會員 發表:16 回覆:56 積分:14 註冊:2005-01-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |