我的問題是:如何通過計算字段來訂購DBGrid。我正在使用C++ Builder Starter Editon,並且在此版本中沒有可用的ClientDataSet以在字段上創建索引,並按列的索引進行排序。所以這不是一個選項。 (在很多線程中閱讀)我正在使用TIBDataSet(ibds在下面),我正在過濾數據。工作得很好......對於DB列,而不是計算出來的......任何有關如何解決這個問題的想法?DBGrid按計算字段排序
void __fastcall TForm1::DBGrid3TitleClick(TColumn *Column)
{
static cIdx = 0;
static String oby = "ASC";
TBookmark CurrentPosition;
TIBDataSet *ibds = IBDS_accountsDist;
CurrentPosition = ibds->GetBookmark();
if (cIdx != Column->Index) {
oby = "ASC"; // ANOTHER column choosen
} else if (oby == "ASC") {
oby = "DESC";
} else oby = "ASC";
cIdx = Column->Index;
ibds->Filtered = false;
switch (Column->Index){
case 0: ibds->Filter = "ORDER BY SumAj "+oby; break; // SumAj is a calculated field => Does not work
case 1: ibds->Filter = "ORDER BY CSAL_ACCOUNTNAME "+ oby; break; // DB-field WORKS FINE
}
ibds->Filtered = true;
ibds->GotoBookmark(CurrentPosition);
}
謝謝你的回答。我仍然必須解決這個問題,並閱讀了很多,現在你的文章...是的,我認爲我們要升級到正常版本的C++ Builder! – 2012-11-14 18:40:25