Retrieve name UserControl

K

kjqua

Hi,
I build a control with method and property, and one specific method.
The InitLayout() see below.

protected override void InitLayout()
{
// base.InitLayout();
if (DesignMode)
{
// I'm DesigneMode
string NomeControllo = ??? ;
label1.ForeColor = Color.Green;
label1.BackColor = Color.Yellow;
label1.Text = "Designe mode" + NomeControllo;
}
else
{ // Not DesigneMode

// Do something
}
}

My target is retrieve the name of my control ( name type in the
Property Panel ) anther i drag my controll in a Form.

Example:
i Name my control "Pippo"
Then when on the Form, in the DesigneMode, i will like to retrieve
the name of the control that i have insert.
 
M

Marc Gravell

er, Name?

However, it might not be set at that point - and there is no
NameChanged or OnNameChanged to listen to for changes... you might
have to deal with this when painting perhaps? Although this would not
be very common on a UserControl.

Marc
 
K

kjqua

er, Name?

However, it might not be set at that point - and there is no
NameChanged or OnNameChanged to listen to for changes... you might
have to deal with this when painting perhaps? Although this would not
be very common on a UserControl.

Marc


What i mind is write in a label encapsulate in the UserControll insert
in a Form, the name Of the UserControll
in Design Mode.


Marco
 

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

Top