Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:42:45+00:00 2026-06-14T11:42:45+00:00

My question is: How can I order a DBGrid by a calculated field. I

  • 0

My question is: How can I order a DBGrid by a calculated field. I am using the C++Builder Starter Editon and do not have a ClientDataSet available in this version to create an Index on the field and order by the index of a column.So this is not an option. (Read this in many threads) I am using an TIBDataSet (ibds below) and I am filtering the data. Works fine….for the DB-columns, not for the calculated ones… Any ideas of how I might get around this problem?

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:42:46+00:00Added an answer on June 14, 2026 at 11:42 am

    You cannot do it. TIBDataSet is a representation of the underlying database. Basically it fetches the records in the order defined in the SQL.

    The easiest way is to use TDBClientDataset but it is not included in Starter version of c++ Builder. You can explore other ways, for example pre-loading all records in a std::list and then use the order function to order the records. Finally you can show them using a simple TGrid o TStringGrid.

    In any case, I recommend to upgrade C++Builder since TClientDataSet is one of the main pieces in most of data projects, specially when you need to create medium-large projects.

    Mixing database specific components like TIBDataSet with the user interface penalizes the scalability and maintenance of the project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following question about JPA: Can I save the order of the
I know this question can be answered by searching in google. But I have
The question is: How can I order by a sql statement using an if
I apologize before hand if this is an obvious question: can Apache 2.0 +
I asked a question about different testing frameworks yesterday. This question can be found
I have the following model (greatly simplified for the purposes of this question): class
I can't seem to find an answer to this question or a good example
I have a system where clients can make orders. After making order they have
Before I ask my question can I please ask not to get a lecture
I am having a rather simple question can anyone tell me why this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.