
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)
posted on 2010-08-06 15:53
Ke 閱讀(935)
評論(0) 編輯 收藏 所屬分類:
powerBuilder