0

我有一个TFDTable连接到一个TGridusingLiveBindings并且数据显示按表本身的索引排序。我希望能够通过单击网格的标题来更改排序顺序。这是我到目前为止所做的:

void __fastcall TmainFrm::Grid7HeaderClick(TColumn *Column)
{
    if(IBS_EntityTable->IndexName == Column->Header)
        return; // if it is being sorted by the same column, don't do anything
    try
    {
        TFDIndex* pIndex;

        IBS_EntityTable->Indexes->BeginUpdate();
        IBS_EntityTable->Indexes->Clear();
        pIndex = IBS_EntityTable->Indexes->Add();
        pIndex->Name = Column->Header;
        pIndex->Fields = Column->Header;
        pIndex->Active = true;
        IBS_EntityTable->IndexName = pIndex->Name;
    }
    __finally
    {
      IBS_EntityTable->Indexes->EndUpdate();
      IBS_EntityTable->Refresh();
    }
}

但排序顺序不会改变。事实上,唯一改变的数据是选定的行。我究竟做错了什么?

谢谢
山姆

4

0 回答 0