Results 1 to 7 of 7

Thread: Missing Label *Solved*

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    Missing Label *Solved*

    I programatically created a label, but it is not visible. However PanelButton (a panel) does show up.

    vb Code:
    1. PanelButton.Parent = Me
    2. PanelButton.Visible = True
    3. PanelButton.Location = New Point(0, 80)
    4. PanelButton.Size = New Size(40, 40)
    5.  
    6. TextLabel.Parent = PanelButton
    7. TextLabel.Visible = True
    8. TextLabel.Location = PanelButton.Location
    9. TextLabel.AutoSize = False
    10. TextLabel.Size = PanelButton.Size
    11. TextLabel.BringToFront()
    12. TextLabel.BackColor = Color.White
    13. TextLabel.ForeColor = Color.Black
    14. TextLabel.TextAlign = ContentAlignment.MiddleCenter
    15. TextLabel.Text = "?"

    Can someone please show me what I'm doing wrong? Thanks
    Last edited by NinjaNic; Aug 6th, 2014 at 05:29 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    Re: Missing Label

    Edit: As you can see, the TextLabel's backcolor is set to white, but (not included here) PanelButton's backcolor is set to red. I don't see any white in the red panel.

  3. #3
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Missing Label

    Code:
    TextLabel.Location = PanelButton.Location
    PanelButton.Location is (0,80) which would put the label below the PanelButton's client area (its height is only 40), and so it would not be visible.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    Re: Missing Label

    I'm not sure I understand because the label is supposed to have the same location and size, so it should be right on the panel.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Missing Label

    the location of a label on a panel is relative to the panel, not the form

  6. #6
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Missing Label

    What Paul said. The location of any control is relative to its Parent.

    If you want the label to be positioned at the top left of the panel, you need to specify the label's location as (0,0).

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    Re: Missing Label

    Oh, thanks! Because of the parent. I forgot. I feel so stupid, but thanks! It works

Tags for this Thread

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