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

  • Home
  • SEARCH
  • 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 8858305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:47:53+00:00 2026-06-14T14:47:53+00:00

I have a column in a DB table which stores pressure. The pressure is

  • 0

I have a column in a DB table which stores pressure. The pressure is always stored as PSI and can be converted to BAR by diving by 14.5.

The user can toggle display of PSI/BAR with a Radio Group.

I was using a TStringGrid and am converting to a TDbGrid – which is quite new to me.

When the user toggles PSI/BAR, how to I update the display in my DB grid? (I imagine that I just execute it’s query again? or Call query.Refresh()?) But how do I do the conversion?

  1. Possibly a stored procedure, although that seems like overkill and stored procedurs are also new to me…
  2. By changing the SELECT statement of my query? But how would I do that? SELECT pressure / 14.5 FROM measurements? Or how?
  3. Or is there an OnBeforeXXX() which I can code? Or OnGetDisplayText() or some such?

I am sure thta this is very basic, but until now I have just been displaying unmanipulated data and now I need a conversion function. Google didn’ty help, but I probably didn’t know what to ask for.

I also want to change the text of the column title, toggling between “Presure (PSI)” and “pressure (BAR)”.
Thanks in advance for any help.

  • 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-14T14:47:55+00:00Added an answer on June 14, 2026 at 2:47 pm

    Code a OnGetText event handler for the pressure field like this:

    type
      TPressureMU = (pmuPSI, pmuBAR);
    
    const
      PSIToBarFactor = 1/14.5;
    
    
    procedure TdmData.qMeasurementsPressureGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    begin
      case PressureMU of
        pmuPSI: Text := FloatToStr(Sender.AsFloat); //Already PSI
        pmuBAR: Text := FloatToStr(Sender.AsFloat * PSIToBarFactor); //ConvertingToBAR
      end
    end;
    

    I’m using a property PressureMU of the declared enumeration to control if the pressure is shown in PSI or BAR measurement unit.

    This way, when the user changes the selection, you just adjust the value of that property.

    If you use persistent fields, you can link the event handler directly to you field using the object inspector, and if not, you can do it by code like this:

    begin
      qMeasurements.FieldByName('Pressure').OnGetText := qMeasurementsPressureGetText;
    end;
    

    where qMeasurementsPressureGetText is the name of the method.

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

Sidebar

Related Questions

I have a table in which a column stores image src which is in
How can I have a column in a table which records the time which
I have an order table in MySQL database, having a field/column which stores the
I have an ID column in a table which stores the row ID number
In a table in my datatase I have a datatime column which stores the
I have table a which stores the user id and the ids of his
i have a table with a column named CustomerName which stores a customer's full
I have a table which has column of descr which stores string values. Some
I have a table, and there is no column which stores a field of
I have one table which stores tags for files. The tags can be of

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.