cxGrid兩個知識點:保持設計時的列寬和隔行著色

來源:互聯網
上載者:User

1、保持合適的列寬且充滿整個地區

cxgrid預設情況下,列有一個屬性MinWidth,這個屬性預設情況下是20,把它改為0。然後把cxgridview的columnAutoWidth設定為true。這樣列寬就會在充滿整個地區的基礎上,根據設計時候的長度進行微調。再也不會在dataset open之後胡亂變換長度了。

2、隔行換色

不能在gridDrawCell事件下寫類似於這種的著色代碼:

  {if   AViewInfo.RecordViewInfo.Index   mod   2   =   0   then
  begin
    ACanvas.Canvas.Brush.Color   := rgb(252,240,235);
    ACanvas.Font.Color := clblack;
  end
  else
  begin
    ACanvas.Canvas.Brush.Color:=clWhite;
    ACanvas.Font.Color := clblack;
  end;

if AViewInfo.Selected then
  begin
    ACanvas.Canvas.Brush.Color := clmenuhighlight;
    ACanvas.Font.Color := clwhite;
  end; }

這樣的著色是有毛病的,如果記錄數超過一屏,用滑鼠往下拉的時候你就會發現不是隔一行著色,而是一個色。因為gridDrawCell只能處理視覺以內的部分。

cxgridview有三個style可以很方便的設定,不用任何代碼,這三個style是:

ContentEven(偶數行style)、ContentOdd(奇數行style)、selection(選中行style)。這三個style可以設定出完美的隔行著色效果。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.