一、在窗口中声明二实例变量:
//取得上次单击的列对象
string i_str_precolumn=""
//判断上次是按升还是按降来排序
integer i_int_clicktime=0
二、在数据窗口控件中的单击事件中写入以下代码:
string str_column,str_format
str_column=dwo.name //取点击的对象
if right(str_column,2) <> "_t" then return
//对于列标题,取得的对象是列名+"_t"
str_column=left(str_column,len(str_column) - 2)
if str_column=i_str_precolumn then //已点击过
if i_int_clicktime=0 then //0表示原来按降序
i_int_clicktime=1
str_format=str_column + " A"
else
i_int_clicktime=0
str_format=str_column + " D"
end if
else
i_int_clicktime=1 //1表示原来按升序
str_format=str_column + " A"
end if
i_str_precolumn = str_column
dw_1.SetSort(str_format)
dw_1.Sort()