Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to Determine The Location Of Label Text In Pixels

How to Determine The Location Of Label Text In Pixels

Scheduled Pinned Locked Moved C#
tutorial
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Ahmad Safwat

    Hi, I need to determine the location of label text in pixels as Margin, Padding, and TextAlign properties change

    H Offline
    H Offline
    Harvey Saayman
    wrote on last edited by
    #2

    no, you need to ask your mother to teach you some manners!!!!:mad:

    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

    you.suck = (you.passion != Programming)

    A 1 Reply Last reply
    0
    • H Harvey Saayman

      no, you need to ask your mother to teach you some manners!!!!:mad:

      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

      you.suck = (you.passion != Programming)

      A Offline
      A Offline
      Ahmad Safwat
      wrote on last edited by
      #3

      Thanks for your answer, but sorry it doesn't help I advice you to ask your mother to teach you some attitude manners

      H 1 Reply Last reply
      0
      • A Ahmad Safwat

        Thanks for your answer, but sorry it doesn't help I advice you to ask your mother to teach you some attitude manners

        H Offline
        H Offline
        Harvey Saayman
        wrote on last edited by
        #4

        Thanx for the 1 vote... some of us are professional developers with alot of work to do and we dont have time to read pointless posts like yours, we keep an eye on these forums to help people to solve problems they are having. NOW WHO THE HELL DO YOU THINK YOU ARE comming in here, and DEMANDING that we do YOUR WORK for you? are you stupid or something? no one here or anywhere else will do your work for you.

        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

        you.suck = (you.passion != Programming)

        A 1 Reply Last reply
        0
        • A Ahmad Safwat

          Hi, I need to determine the location of label text in pixels as Margin, Padding, and TextAlign properties change

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #5

          Ahmad Safwat wrote:

          the location of label text in pixels as Margin, Padding, and TextAlign properties change

          You won't get the location of the text, you can take location of the label instead. Check label.Bounds which gives you a Rectangle instance.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          A 1 Reply Last reply
          0
          • H Harvey Saayman

            Thanx for the 1 vote... some of us are professional developers with alot of work to do and we dont have time to read pointless posts like yours, we keep an eye on these forums to help people to solve problems they are having. NOW WHO THE HELL DO YOU THINK YOU ARE comming in here, and DEMANDING that we do YOUR WORK for you? are you stupid or something? no one here or anywhere else will do your work for you.

            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

            you.suck = (you.passion != Programming)

            A Offline
            A Offline
            Ahmad Safwat
            wrote on last edited by
            #6

            Hi Harvey My post is not pointless, I think you didn't understand it as you may be "stupid or something" My problem is that, I'm working in an application in which I manually simulate some control appearance and draw them in a high resolution image to be printed, now when drawing a Label I need to determine the point(X, Y) on which I print the Label text, as Label.TextAlign may vary from MiddleCenter, to BottomLeft, to TopRight, etc. Now, can you - as a "Professional" developer - help me?? I don't think so.. Even if my question is pointless, it's not enough reason for you to insult me Sorry, but you are not a respectable person

            1 Reply Last reply
            0
            • N N a v a n e e t h

              Ahmad Safwat wrote:

              the location of label text in pixels as Margin, Padding, and TextAlign properties change

              You won't get the location of the text, you can take location of the label instead. Check label.Bounds which gives you a Rectangle instance.

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              A Offline
              A Offline
              Ahmad Safwat
              wrote on last edited by
              #7

              Sorry, but I don't understand how could label.Bounds help me to determine the location of text on Lable??

              A F 2 Replies Last reply
              0
              • A Ahmad Safwat

                Sorry, but I don't understand how could label.Bounds help me to determine the location of text on Lable??

                A Offline
                A Offline
                Alan Balkany
                wrote on last edited by
                #8

                The bounds (which is type Rectangle) has members for top, bottom, right, and left. (left, top) gives you the location of the label's upper-left corner.

                1 Reply Last reply
                0
                • A Ahmad Safwat

                  Sorry, but I don't understand how could label.Bounds help me to determine the location of text on Lable??

                  F Offline
                  F Offline
                  Frank Horn
                  wrote on last edited by
                  #9

                  I guess if you want to know where exactly the text is painted within the label, you'll have to get the control's graphics object, determine the text size with its MeasureString methhod, and calculate the position with a lot of if statements according to alignment and things. But that's kind of like reinventing the label.

                  A 1 Reply Last reply
                  0
                  • F Frank Horn

                    I guess if you want to know where exactly the text is painted within the label, you'll have to get the control's graphics object, determine the text size with its MeasureString methhod, and calculate the position with a lot of if statements according to alignment and things. But that's kind of like reinventing the label.

                    A Offline
                    A Offline
                    Ahmad Safwat
                    wrote on last edited by
                    #10

                    Hi Frank yes that is exactly what I need and I already calculated the position but it's not accurate, so I was asking if there is an existing method to do

                    1 Reply Last reply
                    0
                    • A Ahmad Safwat

                      Hi, I need to determine the location of label text in pixels as Margin, Padding, and TextAlign properties change

                      A Offline
                      A Offline
                      Ahmad Safwat
                      wrote on last edited by
                      #11

                      Hey, can anybody help me?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups