dcsimg
Results 1 to 4 of 4

Thread: (Resolved) Padding on Right Aligned Listview Column Header

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2019
    Posts
    2

    (Resolved) Padding on Right Aligned Listview Column Header

    Hi Folks,

    I've got a problem with my Listview column header text when I right align it.
    The text is so far to the right it's difficult to make out what it says as it is too close to the column separator.

    I'm using owner draw to make the header dark grey / white and I've tried adding spaces to the end of the text but it seems to ignore them at runtime.

    Name:  RightAlign.png
Views: 122
Size:  3.8 KB

    Any Ideas?
    Last edited by Bob Vertex; Jun 14th, 2019 at 02:55 AM. Reason: Resolved

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,167

    Re: Padding on Right Aligned Listview Column Header

    If you're owner-drawing then you can specify exactly where to draw text. Are you doing that? If so, you're doing it wrong. We can't really tell you exactly what's wrong with if we haven't seen it. If you're specifying a rectangle within which to draw the text, it should be fairly obvious that you need to use a rectangle that doesn't go as far to the right.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,167

    Re: Padding on Right Aligned Listview Column Header

    My guess (we shouldn't have to guess because you should show us) is that you are calling DrawString and using a Rectangle that is based on the bounds of the column header. If you call Inflate on that Rectangle, you can make it grow or shrink. If you call Inflate and specify -10 in the X direction and 0 in the Y direction, the Rectangle will remain the same height while each end will move in 5 pixels. That will give you 5 pixels padding on the left and the right when drawing text.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2019
    Posts
    2

    Re: Padding on Right Aligned Listview Column Header

    Quote Originally Posted by jmcilhinney View Post
    My guess (we shouldn't have to guess because you should show us) is that you are calling DrawString and using a Rectangle that is based on the bounds of the column header. If you call Inflate on that Rectangle, you can make it grow or shrink. If you call Inflate and specify -10 in the X direction and 0 in the Y direction, the Rectangle will remain the same height while each end will move in 5 pixels. That will give you 5 pixels padding on the left and the right when drawing text.
    Apologies for not posting the code - my first call for help here :-(

    followed your suggestion and it worked perfectly, thanks so much I was banging my head against a wall there, just couldn't see what was in front of me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width