2 Replies - 4277 Views - Last Post: 31 December 2013 - 10:27 AM Rate Topic: -----

#1 VB_Steven  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 31-December 13

Label on top of Panel: not showing at runtime

Posted 31 December 2013 - 10:09 AM

At Design time:
I have a form that contains a panel. The panel has a background image loaded. The Back Color of the panel is Transparent. The panel has its visible property set to False.

I placed a label on top of the panel and set its Text property to 'some text'. The label has its visible property set to True.

At Run time:
A button click event triggers this:
panel1.Visible = True
label1.BringToFront()

Problem:
The panel becomes visible but the label is no where to be found. The label's fore color is black and the image color on the panel is white. The color of the form is light green.

At Design time I can move the panel around the form and the label moves in concert with the panel; so I'm assuming at this point the label is indeed a child of the panel.

Any ideas why the label will not show in this scenario?

Is This A Good Question/Topic? 0
  • +

Replies To: Label on top of Panel: not showing at runtime

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: Label on top of Panel: not showing at runtime

Posted 31 December 2013 - 10:15 AM

Put a breakpoint where you "panel1.Visible = True" and check out the information on the label.. visibility, content, etc.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6379
  • View blog
  • Posts: 25,770
  • Joined: 12-December 12

Re: Label on top of Panel: not showing at runtime

Posted 31 December 2013 - 10:27 AM

I am curious also why you need to BringToFront? If the label is a child of the panel then it will sit above the panel's background anyway. Perhaps there are other controls that are outside or above the panel. BringToFront would only bring the label above other controls within the same container.

the docs said:

The control is moved to the front of the z-order. If the control is a child of another control, the child control is moved to the front of the z-order. BringToFront does not make a control a top-level control, and it does not raise the Paint event.


http://msdn.microsof...(v=vs.110).aspx

This post has been edited by andrewsw: 31 December 2013 - 10:39 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1