線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1714
推到 Plurk!
推到 Facebook!

ListBox 如何做到每行規則性顯示雙色

尚未結案
corey
一般會員


發表:34
回覆:44
積分:14
註冊:2003-04-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-20 16:46:10 IP:61.230.xxx.xxx 未訂閱
我想要有規則的顯示一行紅底色一行藍底色,可是都顯示紅底色,字都為白色 procedure TFrmUBsio.LBox_ListOrderDrawItem(Control: TWinControl;   Index: Integer; Rect: TRect; State: TOwnerDrawState); begin   LBox_ListOrder.Canvas.Brush.Style := bsSolid;   if LeftStr(LBox_ListOrder.Items.Text,1) = 'B' then begin      LBox_ListOrder.Canvas.Brush.Color := clRed; end   else      LBox_ListOrder.Canvas.Brush.Color := clBlue;   LBox_ListOrder.Canvas.Font.Color := clWhite;   LBox_ListOrder.Canvas.FillRect(Rect); end; 是我觀念不對嗎?還是有寫錯!
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-20 16:51:44 IP:210.3.xxx.xxx 未訂閱
procedure TFrmUBsio.LBox_ListOrderDrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  LBox_ListOrder.Canvas.Brush.Style := bsSolid;
  if LeftStr(LBox_ListOrder.Items[Index],1) = 'B' then begin
     LBox_ListOrder.Canvas.Brush.Color := clRed; end
  else
     LBox_ListOrder.Canvas.Brush.Color := clBlue;
  LBox_ListOrder.Canvas.Font.Color := clWhite;
  LBox_ListOrder.Canvas.FillRect(Rect);
end;
corey
一般會員


發表:34
回覆:44
積分:14
註冊:2003-04-19

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-20 17:11:21 IP:61.230.xxx.xxx 未訂閱
謝謝版主指教 在請問版主,現在字的顏色無法顯示出來,只顯示底色
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-09-20 22:49:27 IP:63.84.xxx.xxx 未訂閱
您好!    
procedure TFrmUBsio.LBox_ListOrderDrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  LBox_ListOrder.Canvas.Brush.Style := bsSolid;
  if LeftStr(LBox_ListOrder.Items[Index],1) = 'B' then
    begin
      LBox_ListOrder.Canvas.Brush.Color := clRed;
    end
  else
    begin
      LBox_ListOrder.Canvas.Brush.Color := clBlue;
    end;
  LBox_ListOrder.Canvas.Font.Color := clWhite;
  LBox_ListOrder.Canvas.FillRect(Rect);
end;
參考看看! ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
corey
一般會員


發表:34
回覆:44
積分:14
註冊:2003-04-19

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-09-20 23:11:32 IP:61.230.xxx.xxx 未訂閱
procedure TFrmUBsio.LBox_ListOrderDrawItem(Control: TWinControl;   Index: Integer; Rect: TRect; State: TOwnerDrawState); begin   LBox_ListOrder.Canvas.Brush.Style := bsSolid;   if LeftStr(LBox_ListOrder.Items[Index],1) = 'B' then     begin       LBox_ListOrder.Canvas.Brush.Color := clRed;     end   else     begin       LBox_ListOrder.Canvas.Brush.Color := clBlue;     end;   LBox_ListOrder.Canvas.Font.Color := clWhite;<--這一行字體已設為白色,可是沒顯示出來 LBox_ListOrder.Canvas.FillRect(Rect); end; 請各位大大及版主幫幫忙....謝謝
TATSU
版主


發表:50
回覆:135
積分:62
註冊:2003-01-16

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-09-21 07:20:25 IP:218.102.xxx.xxx 未訂閱
    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  ListBox1.Canvas.Brush.Style := bsSolid;      if Copy(ListBox1.Items[Index],1,1) = 'B' then
    ListBox1.Canvas.Brush.Color := clRed
  else
    ListBox1.Canvas.Brush.Color := clBlue;      ListBox1.Canvas.FillRect(Rect);
  ListBox1.Canvas.Font.Color := clWhite ; 
  ListBox1.Canvas.TextOut(Rect.Left   2, Rect.Top  2,ListBox1.Items [Index]);
  
end;
系統時間:2024-05-18 13:16:41
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!