Hi,
I'm trying to build a custom control derived from the UserControl class.
I've got the basics working and have been trying to get the name of the
control to show up on the form while in design-mode.
I expected that this.Name would give me the name as defined in the designer.
Instead, it shows the name of the class.
If I put two MapViewer instances on the form and set the name property
to 'Map1' and 'Map2', both maps show 'drawingSurface' in the left corner
of the control. (see the 'this.Name' in the source below)
Can any of you point me in the right direction?
And can you advise me on a good book dedicated to custom control
designing?
Thanks in advance!
Marcel
namespace MapViewer
{
public partial class drawingSurface : UserControl
{
public drawingSurface()
{
InitializeComponent();
}
override protected void OnPaintBackground(PaintEventArgs pevent)
{
// Do nothing!
}
private void drawingSurface_Paint(object sender, PaintEventArgs e)
{
if (this.DesignMode)
{
e.Graphics.Clear(SystemColors.Control);
e.Graphics.DrawRectangle(
Pens.Black,
this.ClientRectangle.Left, this.ClientRectangle.Top,
this.ClientRectangle.Right-1,
this.ClientRectangle.Bottom-1);
e.Graphics.DrawString(this.Name, this.Font, Brushes.Black,
new PointF(0, 0));
}
}
}
}
Matt - 27 Feb 2008 19:33 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> I expected that this.Name would give me the name as defined in the designer.
> Instead, it shows the name of the class.
Try Site.Name
Matt
Marcel Overweel - 28 Feb 2008 07:48 GMT
> "Matt" <matttelles@sprynet.com> schreef in bericht
> news:64f1a416-af63-4f03-9d4d-84dc1f744e0c@q78g2000hsh.googlegroups.com...
[quoted text clipped - 11 lines]
>
> Matt
Sometimes it's sooo easy.. if you know where to look...
Thanks Matt!
regards,
Marcel