Label in Panl Derived Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a control that inherits from the Panel Class. To this, I added a
label which I want to use as a caption in my derived control. However, I
can't get the label to show up in the panel. I tried a text box and it works
fine. I've tried everything on the label from visible=True, BringToFront,
etc. but I can't get it to show up.

Is this a bug in VS or can one just not do this?
 
Dennis,

When you do not set a border or text in a label, you do not see it. Is that
not simple the problem?

Cor
 
Thanks Cor but I've tried different borders as well as text. If I just add a
panel to a form then a label to the panel, it works fine. However, it
doesn't work from my derived control (derived from a panel). Thanks for
answer though.
 
Dennis,

I have selected an item usercontrol
Draged on that a panel docked it.
Draged "on" that a label

Build the solution

Set that usercontrol on a form

Debug

And than I see "Label1"

I hope this helps somehow?

Cor
 
Yes that works fine. But what I actually have is a control that I'm working
on that derives from a panel class. I add a label control to my derived
control and save that as a dll assembly.

I then start a new project and add my new control to the form. It's then
that I can't get the label to show up. If I add a label in my new project to
my control, it shows up fine but the one I added before doesn't show.

What I'm trying to do is create a control that has some Cells in a grid. I
add a text box and a label and then save it as user control assembly.dll.

I then start my new project and add an instance of my new control to a form.
The textbox shows up fine but the label won't show nor will a combo box,
listbox, button, etc. Only the text box shows up. The controls are there
becuse I can reference them in my control but no matter what I do, they
aren't visible.

Sorry if this is confusing. It's just that I'm getting frustrated with VS
not doing what it should do easily.
 
Dennis,

When you give your questions in riddles you get the same answers and does
cost a lot of time to the people who wants to help in this newsgroup.

In my opinion is the last question very different from your first as well as
from your second.

Are you sure this code is at least in your usercontrol about the label?
Me.Label1.Location = _
New System.Drawing.Point(1, 1)
Me.Label1.Name = "Label1"
Me.Label1.Text = "MyLabel"
Me.Controls.Add(Me.Label1)

And than especially the last row?

I hope this helps?

Cor
 
Sorry about the lengthy explaination but I wasn't sure you were understanding
my problem. Your last note solved my problem. The line
"Me.Controls.Add(Me.Label1) wasn't being added by the Designer. All the
other lines were added correctly but not that one. Strange the Designer
would not add the most important line. Thanks for help. All the controls I
add to my control show up fine now if I add the line manually.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top