鼠标单击TabSequence=0的单元格时黑色选中色变为其他颜色

1、首先将DW属性中的Column Moving 和Mouse Selection 两项取消选中;

2、在 DW 的Clicked 事件中写代码:

    //此处声明所用到的相关变量; 

    long  ll_curcol,ll_pos,ll_cols

    string  ls_modstring,ls_colname,ls_color_1,ls_color_2,ls_curcol

    if row = 0 then return

    //此处给两个颜色变量赋值; 

    ls_color_1 = string(rgb(255,255,255)) 

    ls_color_2 = string(15780518) //此处设置选中单元格为SKY天蓝色

    //此处获取当前列号和总列数; 

    //ll_curcol=dw_1.getcolumn()

    ls_curcol = left(dw_1.GetObjectAtPointer(),pos(dw_1.GetObjectAtPointer(),"~t") - 1)

    ll_cols = long(dw_1.Object.DataWindow.Column.Count) 

    //此处将所有列的BACKGROUND的 MODE属性设为不透明;(注:下面两句其实可以放到FORM的OPEN事件或DW的CONSTRUCTOR里面执行,可以提高效率;) 

dw_1.setredraw(false)

for  ll_pos = 1  to  ll_cols 

    ls_colname = dw_1.Describe("#"+string(ll_pos)+".Name") 

    dw_1.Modify(ls_colname+".Background.Mode='0'") 

next 

   //此处将所操作列的Background.Color属性设为带IF判断的表达式,而除此之外的各列的背景表达式均设为恒值; 

 for  ll_pos = 1  to  ll_cols 

     ls_colname = dw_1.Describe("#"+string(ll_pos)+".Name") 

     //if  ll_pos<>  ll_curcol  then 

     if  ls_colname <> ls_curcol then

         ls_modstring = ls_colname+".Background.Color='"+ls_color_1+"'" 

     else 

         ls_modstring = ls_colname+".Background.Color='"+ls_color_1+"  ~t  if  (getrow()=currentrow(),"+ls_color_2+","+ls_color_1+")'" 

     end  if 

     //此处执行背景颜色修改; 

     dw_1.Modify(ls_modstring)   

 next 

   //刷新显示新的背景颜色;

   dw_1.setredraw(true)


本文来自CSDN博客,转载请标明出处:http://www.blogjava.net/keweibo/articles/328136.html

猜你喜欢

转载自blog.csdn.net/tlammon/article/details/51205248