起步软件技术论坛-X3

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: beidou

【结帖】光标定位问题**

[复制链接]
 楼主| 发表于 2008-3-20 10:48:10 | 显示全部楼层
这样只有那个字段列变色;不会把每个字段都写一下赋颜色值吧?
回复 支持 反对

使用道具 举报

发表于 2008-3-20 11:56:02 | 显示全部楼层
是的,目前是根据每个单元格的显示文本来判断的。所以导致同一行的其他单元格无法判断颜色。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-20 14:02:06 | 显示全部楼层
请帮忙解决一下根据如上条件,能改变一行的问题。
回复 支持 反对

使用道具 举报

发表于 2008-3-20 14:03:33 | 显示全部楼层
那用下面的方式吧,比如要根据datagrid的第二列的值来控制颜色显示的话,用下面的代码看看
  if (ANode.Strings[1] = '4')
     then
  begin
    AFont.Color := Business.System.Graphics.clRed;

效果图

snap2.png

8.35 KB, 下载次数: 139

回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-20 15:05:09 | 显示全部楼层
如果只根据一个字段来控制两种颜色OK了。
但是,发现,如果一个DataGrid中的A字段为0显示红色;字段B为0显示蓝色;字段C<>' '显示黑色,就不能实现了。如下代码:

if (ANode.Strings[16]='0') or (ANode.Strings[16]='') then
      begin
        AFont.Color := Business.System.Graphics.clWhite;
        AFont.Color := Business.System.Graphics.clRed;
      end;

    //已分摊完成
      if ANode.Strings[17]='0' then
      begin
        AFont.Color := Business.System.Graphics.clWhite;
        AFont.Color := Business.System.Graphics.clGreen;
      end;

   //已结算
      if ANode.Strings[13]<>'' then
      begin
        AFont.Color := Business.System.Graphics.clWhite;
        AFont.Color := Business.System.Graphics.clBlack;
      end;

       if (ANode.Strings[17]<>'0') and (ANode.Strings[17]='') and (ANode.Strings[16]<>'0') and (ANode.Strings[13]='') then
       begin
         AFont.Color := Business.System.Graphics.clWhite;
         AFont.Color := Business.System.Graphics.clBlue;
       end;
回复 支持 反对

使用道具 举报

发表于 2008-3-20 15:13:42 | 显示全部楼层
那楼上的就不能那么写了吧,关键是你条件的控制。
回复 支持 反对

使用道具 举报

发表于 2008-3-20 15:17:06 | 显示全部楼层
比如说这样
  if (ANode.Strings[1] <> '4') and (ANode.Strings[2] <> '4') then
    AFont.Color := Business.System.Graphics.clBlue
  else
  begin
    if ANode.Strings[1] = '4' then
    begin
      AFont.Color := Business.System.Graphics.clRed;
    end
    else
    begin
      if ANode.Strings[2] = '4' then
        AFont.Color := Business.System.Graphics.clGreen;
    end;
  end;
关键看楼主你自己的条件依据

效果图

snap1.png

14.04 KB, 下载次数: 126

回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-20 15:32:56 | 显示全部楼层
搞定了,关键是我忽略了几个隐藏列,谢谢!
回复 支持 反对

使用道具 举报

发表于 2008-3-20 15:44:00 | 显示全部楼层
好,不客气,揭帖!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-9 00:44 , Processed in 0.040835 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表