Results 1 to 7 of 7

Thread: Measuring A String

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Posts
    105

    Measuring A String

    I'M creating a custom userlist for a chatroom program, and I'M trying to color the usernames on the list, but for some reason when I'M going through the name to color the names with the different colors when I measure the strings it keeps getting a space in between.

    Code:
     Dim NameFont As New Font("Tahoma", 8, FontStyle.Bold, GraphicsUnit.Point)
    
    
    	'e.ItemRect is the rectangle I'M drawing in
    
    
    	Dim UserName as String = "#c1#J#c2#o#c3#s#c4#h#c5#i#c6#e
    
    	UserName = "#c9#" & UserName
    
            Dim StartPos As Double = e.ItemRect.Left + 56
    
    
    
            Dim Spl() As String = Split(UserName, "#c")
    
    
            For Each Item As String In Spl
                Dim TColor As Color = ColorHelper.GetColorFromNumber(ColorHelper.ExtractColorNumber(Item))
                Debug.WriteLine(TColor.ToString)
    
                Dim RT As String = ColorHelper.ExtractRealString(Item)
              
                Dim NBrush As New SolidBrush(TColor)
    
                e.Graphics.DrawString(RT, NameFont, NBrush, StartPos, e.ItemRect.Top + 2)
    
    
    	    'Right here, there always seems to be a space inbetween when there shouldn't be.
    
                StartPos += e.Graphics.MeasureString(RT, NameFont).ToPointF.X
    
    
            Next
    Last edited by JoshHilton; Jun 27th, 2009 at 04:13 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width