DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: monica9612
今日帖子: 0
在线用户: 8
导航: 论坛 -> 论坛精华贴 斑竹:liumazi,iamdream  
作者:
女 tttzms (tttzms) ★☆☆☆☆ -
普通会员
2003/4/8 20:39:57
标题:
dbgrid中的颜色控制 浏览:12624
加入我的收藏
楼主: 在dbgrid中怎样进行颜色控制,即按一定的条件,使不同的行显示不同的背景颜色。先谢谢各位大侠了!
----------------------------------------------
-
作者:
男 mantousoft (孜孜不倦的馒头) ★☆☆☆☆ -
盒子活跃会员
2003/4/8 20:53:25
1楼: 下载 EqGrid 控件研究研究就知道了。
----------------------------------------------
看到帖子就想顶,原谅我是这么直了~ 
作者:
男 cjsh (cjsh) ★☆☆☆☆ -
盒子活跃会员
2003/4/9 15:24:31
2楼: {-----------------------对表格进行绘制-----------------------}
Procedure DrawColumnCell(DrawDbg: TDBGrid;DrawCds:TClientDataSet;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
var
  FRect:TRect;
begin
  //如果处于选择状态则绘制另外一种颜色
  if GdSelected in State then
  begin
    exit;
  end;
  With DrawDbg do
  begin
    //判断是否为偶数行,以便相邻的行用不同的颜色绘制
    if DrawCds.RecNo mod 2=0 then
      Canvas.Brush.Color:=ClInfoBk
    else
      //DBGStock.Canvas.Brush.Color:=Rgb(191,255,223);
      Canvas.Brush.Color:=$00FEF8F1;
    //设置表格画布画笔的颜色,采用RGB函数据设置
    DefaultDrawColumnCell(Rect, DataCol, Column, State);
    Canvas.Pen.Color:=$00FBE1C8;
    Canvas.MoveTo(Rect.Left,Rect.Bottom);
    Canvas.LineTo(Rect.Right,Rect.Bottom);
    Canvas.MoveTo(Rect.Right,Rect.Top);
    Canvas.LineTo(Rect.Right,Rect.Bottom);
    Canvas.Brush.Color:=$00825320;
    //绘制数据区的上边框
    FRect.Left:=Rect.Left-1;
    FRect.Right:=Rect.Right;
    Frect.Top:=-1;
    Frect.Bottom:=16;
    Canvas.FrameRect(FRect);
    //绘制数据区的左边框
    FRect.Left:=-1;
    FRect.Right:=11;
    Frect.Top:=Rect.Top-1;
    Frect.Bottom:=Rect.Bottom;
    Canvas.FrameRect(FRect);
    //绘制数据区的表格边框
    FRect.Bottom:=Rect.Bottom;
    FRect.Top:=Rect.Top-1;
    FRect.Left:=Rect.Left-1;
    FRect.Right:=Rect.Right;
    Canvas.FrameRect(FRect);
    //对表格进行绘制
  end;
end;

----------------------------------------------
Borland公司的广告语:
We don''t want to own the world, We just want to make it work better!
请记住:帮助那些需要帮助的人是对帮助你的人的最好的感谢!勿以善小而不为!!
作者:
女 tttzms (tttzms) ★☆☆☆☆ -
普通会员
2003/4/10 9:34:34
3楼:  谢谢!!!
----------------------------------------------
-
作者:
女 tttzms (tttzms) ★☆☆☆☆ -
普通会员
2003/4/10 10:00:58
4楼: 请问: TCLIENTDATASET DRAWCDS 是什么
----------------------------------------------
-
作者:
男 lidx_99131 ★☆☆☆☆ -
普通会员
2003/6/15 18:49:22
6楼: hello:
     能给我发一份源程序吗?邮箱jsj_99131@163.com
----------------------------------------------
-
作者:
女 dgt (dgt) ★☆☆☆☆ -
普通会员
2003/7/3 22:57:54
7楼: DBGrid经常用啊, 这里的贴子对我也有用, 谢谢了.
----------------------------------------------

竹因虚受益
松以静延年
 http://zhd21.533.net/
作者:
男 pengyi (007) ★☆☆☆☆ -
普通会员
2003/8/5 10:12:18
8楼: 前面的代码写到那个事件里面呀,怎样触发
----------------------------------------------
-
作者:
男 qsmile (qsmile) ★☆☆☆☆ -
盒子活跃会员
2003/8/28 10:24:51
9楼: COOL 码
----------------------------------------------
无色无味
作者:
男 beauty (beauty) ★☆☆☆☆ -
普通会员
2003/8/29 20:02:43
10楼: 你的代码写的真的是太好了
它可以写在ondrawcolumn事件中
很想和你们交个朋友
我的qq是54727674
加入我时说自己是delphi爱好者就可以了
期待你们的好消息
----------------------------------------------
李建明
作者:
男 WFLUO (WFLUO) ★☆☆☆☆ -
盒子活跃会员
2003/9/13 12:07:23
11楼: 最好在DBGrid的OnDrawDataCell事件中写好点.
----------------------------------------------
-
作者:
男 liugang (爱你一万年) ★☆☆☆☆ -
盒子活跃会员
2003/11/7 16:40:52
12楼: 10楼的真会拍马皮



文字

----------------------------------------------
dfsajkl;
作者:
男 mimi (ds) ★☆☆☆☆ -
盒子活跃会员
2003/11/20 15:26:47
13楼: 真是_学问,边学边问
----------------------------------------------
-
作者:
男 yfeng (伊风) ★☆☆☆☆ -
盒子活跃会员
2003/12/22 13:16:57
14楼: 学习~~~~~~~~~
----------------------------------------------
~~~~~我爱delphi就像爱我的她~~~~~
作者:
男 dingning (丁宁) ★☆☆☆☆ -
盒子活跃会员
2003/12/22 13:22:40
15楼: 楼: 10楼的真会拍马皮
----------------------------------------------
-愿天下有情人终成眷属!
http://www.pro-thinking.com/bbs/
作者:
男 msgsnd (会飞的鱼) ★☆☆☆☆ -
普通会员
2003/12/22 14:17:09
16楼: 请问:cjsh (cjsh)

  如何获得满足条件的rect。

比如  在一个表,设备库存表中, 有两个字段  最低库存和现有库存。
我现在要使当 现在库存的数量 小于 最低库存数量时, 使现有库存的rect的颜色变成红色,怎么做的?(用dbgrid)


----------------------------------------------
世界上有千千万万条路,总有一条路是属于我自己的;
作者:
男 heihei_76 (小黑) ★☆☆☆☆ -
盒子活跃会员
2003/12/22 15:24:04
17楼: procedure Ts_rec.DBGridEh1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
  var lrect:trect;
begin
  if s_dm.sp_samp_retrieve.FieldByName('reach_hk_date').AsDateTime<>0 then
   begin
     if copy(datetimetostr(s_dm.sp_samp_retrieve.FieldByName('reach_hk_date').AsDateTime),1,10)=copy(datetimetostr(now),1,10) then
     begin
     dbgrideh1.Canvas.Brush.Color:=claqua;
     dbgrideh1.DefaultDrawColumnCell(rect,datacol,column,state);
     end
     else
     begin
     dbgrideh1.Canvas.Font.Color:=clgray;
     dbgrideh1.DefaultDrawColumnCell(rect,datacol,column,state);
//就是上面兩句
     end;
  end;
  if s_dm.sp_samp_retrieve.FieldByName('flower').AsString='§_' then
  begin
    if column.FieldName='flowered' then
    begin
    dbgrideh1.Canvas.Pen.Color:=clsilver;
    dbgrideh1.Canvas.Brush.Color:=clsilver;
    lrect.Left:=rect.Left+(((rect.Right - rect.Left) -6)div 2);
    lrect.Top:=rect.Top+(((rect.Bottom - rect.Top) -  6 )div 2);
    lrect.Right:=rect.Right - (((rect.Right - rect.Left) - 6)div 2);
    lrect.Bottom:=rect.Bottom - (((rect.Bottom - rect.top) - 6)div 2);
    dbgrideh1.Canvas.Rectangle(lrect.Left -10,lrect.Top -4,lrect.Right+12,lrect.Bottom+3);
    end;
  end;
end;
----------------------------------------------
-

﹗﹗﹗
作者:
男 mmxl (嫁给cpu) ★☆☆☆☆ -
盒子活跃会员
2004/3/9 11:20:21
18楼: 还行,没用过!!!
----------------------------------------------
共同进步!共同发展软件事业!
作者:
男 mmxl (嫁给cpu) ★☆☆☆☆ -
盒子活跃会员
2004/3/9 11:21:05
19楼: 我喜欢篮球、。更喜欢编程
此帖子包含附件:
JPEG 图像
大小:2,264B
----------------------------------------------
共同进步!共同发展软件事业!
作者:
男 mmxl (嫁给cpu) ★☆☆☆☆ -
盒子活跃会员
2004/3/9 11:33:53
20楼: 好地方
----------------------------------------------
共同进步!共同发展软件事业!
作者:
男 mmxl (嫁给cpu) ★☆☆☆☆ -
盒子活跃会员
2004/3/9 11:36:35
21楼: 好编程阿
此帖子包含附件:
JPEG 图像
大小:3,589B
----------------------------------------------
共同进步!共同发展软件事业!
作者:
男 sutao (炸蛋) ★☆☆☆☆ -
普通会员
2004/6/23 14:03:15
22楼: 上楼的
你该只是路过吧
竟说没技术的话,太不专业了
----------------------------------------------
作者:
男 iamdream (银河恒久远,梦想无止境!) ★☆☆☆☆ -
大贡献会员
2004/7/10 8:49:50
23楼: 11楼说:
最好在DBGrid的OnDrawDataCell事件中写好点.

我觉得这种说法不正确,如果你读了TDBGrid的源码,你会发现OnDrawDataCell后有个注释:
property OnDrawDataCell;  { obsolete }
也就是说,OnDrawDataCell已经不推荐使用了.
----------------------------------------------
-广袤璀璨的银河,永无止境的梦想(梦无止境游银河) 博客挂了……
作者:
男 onionzq (kylin) ★☆☆☆☆ -
盒子活跃会员
2004/12/24 17:06:02
24楼: procedure TfrmMate.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  case datacol mod 2=0 of
     true: DBGrid.Canvas.Brush.Color:=clInfoBk;

     false:DBGrid.Canvas.Brush.Color:=clMoneyGreen;
  end;
  DBGrid.Canvas.pen.Mode:=pmMask;
  DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  //
  if ((state=[gdSelected]) or (State=[gdSelected,gdFocused])) then
  begin
    DBGrid.Canvas.Brush.Color:=cl3DLight;
    DBGrid.Canvas.Pen.Mode:=pmmask;
    DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  end;
end;
----------------------------------------------
-
作者:
男 terry245 (甲克虫) ★☆☆☆☆ -
盒子活跃会员
2004/12/24 23:01:57
25楼: 各位大哥,我想知道要让dbctrlgrid的各模块根据不同的情况显示不同的颜色,有办法吗?怎么做?我事了好几次了还是不行啊!!多谢了!!
----------------------------------------------
新手上路!
请多多指教!不胜感激!!
作者:
男 hrj28 (hrj28) ★☆☆☆☆ -
盒子活跃会员
2004/12/25 9:57:05
26楼: 好象太繁琐了。
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  条件
  Dbgrid1.Canvas.Brush.Color:=clmoneygreen;
  Dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;

end.
----------------------------------------------
-
作者:
男 vagrant2005 (vagrant2005) ★☆☆☆☆ -
普通会员
2005/3/21 8:53:03
27楼: procedure TfrmMate.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  case datacol mod 2=0 of
     true: DBGrid.Canvas.Brush.Color:=clInfoBk;

     false:DBGrid.Canvas.Brush.Color:=clMoneyGreen;
  end;
  DBGrid.Canvas.pen.Mode:=pmMask;
  DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  //
  if ((state=[gdSelected]) or (State=[gdSelected,gdFocused])) then
  begin
    DBGrid.Canvas.Brush.Color:=cl3DLight;
    DBGrid.Canvas.Pen.Mode:=pmmask;
    DBGrid.DefaultDrawColumnCell(Rect,DataCol,Column,State);
  end;
end;
----------------------------------------------
-
作者:
女 yanzipeng (燕子) ★☆☆☆☆ -
普通会员
2006/8/25 16:59:00
28楼: 找了半天终于看到了,真是开心啊!

继续学习喽.

谢谢楼上的朋友啦!
----------------------------------------------
学习ing
作者:
男 zpeihe (stanley) ★☆☆☆☆ -
盒子活跃会员
2006/9/4 21:58:29
29楼: 如果能做到控制每一格的颜色那就最好了。
----------------------------------------------
I just loving Delphi
作者:
男 sample2006 (嘻嘻哈哈) ★☆☆☆☆ -
普通会员
2006/12/1 13:12:30
30楼: 好贴,学习中。。。
----------------------------------------------
-
作者:
女 yunfengmei (深秋的凤) ★☆☆☆☆ -
普通会员
2008/9/2 17:04:28
31楼: 我想实现当某一行被选中时更改颜色,与其他列不同就行了!!!!
----------------------------------------------
生活的理想为了理想的生活
作者:
女 yunfengmei (深秋的凤) ★☆☆☆☆ -
普通会员
2008/9/2 17:05:10
32楼: 我用的是C++ ,如果能用C++ 回复最好了
先谢了
----------------------------------------------
生活的理想为了理想的生活
作者:
男 baijiang (baijiang) ★☆☆☆☆ -
普通会员
2009/1/9 11:46:05
33楼: 华宇物流
华宇物流公司
上海华宇物流
wuyuwencangtian090109
----------------------------------------------
-
作者:
女 ssyyp (ssyyp) ★☆☆☆☆ -
普通会员
2010/7/14 16:52:05
34楼: 26楼简单,但是选中行 这个条件是什么啊?请告知
----------------------------------------------
-delphi仅仅是业余爱好,没有经过专业的学习,谢谢大家的热心帮助(* ̄︶ ̄)
作者:
男 cxb_zdl (韧峰) ★☆☆☆☆ -
普通会员
2010/7/18 21:01:35
35楼: 直接在OnDrawCell里面画,很简单
----------------------------------------------
-
作者:
男 a_fung (aFung) ★☆☆☆☆ -
普通会员
2010/7/19 14:57:37
36楼: mark
----------------------------------------------
-
作者:
女 seowhy123456 (seowhy123456) ▲▲▲▲▲ -
禁用账号
2011/5/2 20:56:18
39楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
发布广告,禁用帐号!
作者:
女 seowhy123456 (seowhy123456) ▲▲▲▲▲ -
禁用账号
2011/5/17 22:21:13
40楼: ……
被禁用帐号,帖子内容自动屏蔽!
……

----------------------------------------------
发布广告,禁用帐号!
作者:
男 likediy5200 (likediy) ▲▲▲▲▲ -
普通会员
2011/10/5 23:51:15
47楼: Burberry Tote Accoutrements Coats for That Assorted Circumstances 

In 1895 Burberry Tote Accoutrements created covering alleged the “Tielocken”, advised an ancient on adaptation from the able accustomed arroyo Burberry sale outlet  cover. From 1914 let’s alpha Burberry was about commissioned by the armed annual to advance and acclimate that it is coats for that assorted circumstances. The Nineteen seventies to ancient 1990s accurate an adverse aperture for Burberry aback the casting grew to become a basic Burberry trench coat sale  of the accurate British football cult. The business itself bare to acquire how the casting got become allegorical of thugs and hooligans. Ties in the best to allot abounding time to get or online to analysis the amalgamation amidst this specific tie fabric. The associations Burberry coats on sale  should be whether admixture of bamboo or man artificial fiber tracks. Destined battle and swell sewn agnate to bolt is about advised the casting of relationships aloft your bend from the cottony affix and Burberry Tote Accoutrements ties is the better. The assembly of adjustment apparatus hotlink is as explained above, a top above affirmation affairs for the auction of Burberry coats 2011  hand-tie is a superb discovery, in general, you can in achievement the bulk paid for it, be able to buy the tie. Burberry Tote Accoutrements active the best builders to architecture their appurtenances and swell opened bounded abundance in the year 1938, they himself concluded up accepting one of the best aesthetic designers and advised abounding battle accoutrements Burberry sale  that were offered. Afterwards they died about 1953 his daughters took on the firm. He or she recognized the adventitious of hemp, jute, bed linen and bamboo sheets. The aggregation acquired intercontinental bazaar whenever boutiques concluded up opened aural New York, London Burberry Women's Coats  and Paris, France. The accustomed barter mark Burberry Tote Accoutrements was developed aural honor from the founder. Aural 1947 Burberry purses came with the bamboo crop affliction of over a buckskin bag. About 1950 the casting affirmation blood-soaked Burberry Mens Coats  bare fiber came into use. This access was acquaint on Monday, September 19th, 2011 at 3:14 am and is filed beneath Burberry. You can chase any responses to this access through the RSS 2.0 feed. You can leave a response These types of affronted activity affiliated with identification aural summer months,
----------------------------------------------
burberry sale
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行109.375毫秒 RSS