DataGrid Column Right Align Caption Text Getting Cut Off

Posted on 2005-05-02
Last Modified: 2012-08-14
I have a datagrid that I want to align the values to the right.  The number in the grid look correct however in the caption the T in Amount is getting cut off.  I have tried adding spaces before and after the caption text but nothing seems to work.  Any help would be greatly appreciated.
Question by:d_potts
    LVL 2

    Author Comment

    Side Note.  I have the onPaint in the Datagrid overwritten.  Could this have something do with it.
    LVL 2

    Author Comment

    Sorry I ment in the DatagridColumnsSysle for the textbox column
    LVL 34

    Expert Comment

    Assuming that the caption you refer to is the column header - DataColumn.ColumnName - I've not seen this before.  

    1) What is in the overriding of the DataGrid.OnPaint?

    And what happens if

    2) you increase the width of the column?


    3) change the font to non-proportional - e.g Courier New?

    LVL 14

    Assisted Solution

    Hi d_potts,

    I've seen this same question many times in this forum. That is a known problem with datagrid. Check out these links:
    LVL 34

    Accepted Solution


    So it is.  I must never have right-aligned the rightmost column before.  Having now tested doing so, I see the problem.


    If you don't want to shift the Amount column further left in the grid, a workaround seems to be to rightpad the Amount with, e.g., a single point - "Amount."  Spaces just seem to get stripped off, but you can us any character that is narrow enough to get hidden and leave just the "Amount" showing.  A point worked on my test, but it will no doubt be a function of what font you're using.

    LVL 2

    Author Comment

    Thanks Guys.   I never though to use a '.'  I tried spaces and they never worked.  It's things like this in .NEt that drive me nuts.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now