Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Name of an instance in designer mode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcel Overweel - 26 Feb 2008 11:36 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.