1.定义字段
Boolean ib_SetSort = true;
string is_SortType = "D";
2.
/// <summary>dw排序
///
/// </summary>
/// <param name="sortDW">要排序的dw</param>
private void DWSetSort(Sybase.DataWindow.DataWindowControl sortDW) //数据窗口排序
{
try
{
string is_OrderCol = "";
if (this.ib_SetSort == true)
{
string ls_CurObj = "";// ls_CurCol = "";
int li_LinePos = 0;
int ll_CurRowNumber = 0;
ls_CurObj = sortDW.ObjectUnderMouse.Gob.Name; //得出objectName
ll_CurRowNumber = sortDW.ObjectUnderMouse.RowNumber; //得出当前Row
//li_LinePos = Convert.ToInt32(sortDW.Describe(ls_CurObj + ".X")) + (Convert.ToInt32(sortDW.Describe(ls_CurObj + ".Width")) - 20);
if (sortDW.Describe(ls_CurObj + ".Band") == "header")
{
if (ll_CurRowNumber == 0 & sortDW.Describe(ls_CurObj + ".Text") != "!")
{
is_OrderCol = ls_CurObj.Substring(0, ls_CurObj.Length - 2);
if (is_SortType == "A")
{
li_LinePos -= 20;
//DataWindowSort(sortDW, li_LinePos, is_OrderCol, is_SortType);
sortDW.SetSort(is_OrderCol + " " + is_SortType);
sortDW.Sort();
is_SortType = "D";
}
else
{
//DataWindowSort(sortDW, li_LinePos, is_OrderCol, is_SortType);
sortDW.SetSort(is_OrderCol + " " + is_SortType);
sortDW.Sort();
is_SortType = "A";
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"排序错误!");
}
}
3.
private void dw_2_Click(object sender, EventArgs e)
{
DWSetSort(dw_2);
}