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 8813429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:50:54+00:00 2026-06-14T03:50:54+00:00

Continuing with the project started in: How to auto fit/scale DBGrid's (or other similar)

  • 0

Continuing with the project started in:

How to auto fit/scale DBGrid's (or other similar) columns widths according to its contents?

How to calculate the “Left” Property to center a Text in a DBGrid Cell?

When we call OnDrawColumnCell and use the Canvas to write a text in replacement of the default draw of the grid, how may we calculate the position of the text when we want to center it on the cell?

  • 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-14T03:50:55+00:00Added an answer on June 14, 2026 at 3:50 am

    Don’t. Paint the text with DrawText/DrawTextEx and specify DT_CENTER in the format parameter. See also Draw text multiline in the centre of a rect.

    Or if you want or need to calculate it yourself:

    procedure DrawCenteredText(Canvas: TCanvas; const S: String; R: TRect);
    var
      Left: Integer;
    begin
      Left := R.Left + (R.Right - R.Left - Canvas.TextWidth(S)) div 2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an iOS Project with folders containing *.m files, similar to packages, one will
I recently started using Mac OS X for a flex/actionscript project and having a
I have started to use git for my projects, when I create a project
I started this project a long long time ago when I was just beginning
Sorry about the confusing title. I recently started doing this in my project, and
I've started a simple project in which it must get an image containing text
I'm getting started on a new MVC project where there are some peculiar rules
We've recently started a small-ish project for a mobile site demo w/.NET4; jquery-mobile has
As of late, we started a pretty large project (C# XNA game). It seemed
I just started using code contracts in my project. However, I have a problem

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.