3 Replies - 1215 Views - Last Post: 13 October 2012 - 05:06 AM Rate Topic: -----

#1 Coding in the name of  Icon User is offline

  • D.I.C Head

Reputation: 67
  • View blog
  • Posts: 232
  • Joined: 07-July 10

[Solved] The name '<name>' is already in use by anothe

Posted 12 October 2012 - 03:25 PM

Hello, I'm working on a Windows Forms program in VB .NET for my college coursework. To reduce duplication of code I've moved some things to custom controls to be used in multiple forms. One of these controls, called CustomerSelector, is in use by two different forms and I'm trying to give them the same name in each form. But VB gives me a "Property value is not valid" error with the message "The name ctlCustomerSelector is already in use by another component". Why am I getting this error when the custom controls should be members of different classes. It's doubly confusing because I have another custom control which is in use by two different forms with the same name in each form, and I don't get this error.

Thanks.

This post has been edited by Coding in the name of: 13 October 2012 - 05:07 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [Solved] The name '<name>' is already in use by anothe

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: [Solved] The name '<name>' is already in use by anothe

Posted 12 October 2012 - 03:41 PM

If there on same form with the same identifier / name, of cause this is an issue. As all the controls need uniquely identifiable. How would the compiler know which you meant.

The Fully Qualified Namespace of the control is in the following format.
{Namespace}.{Form}.{Control}.{Method/Property}
Eg
MySpecialProject.Form1.TextBox1.Text
MySpecialProject.Form2.TextBox1.Text

Same Name but different forms.
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: [Solved] The name '<name>' is already in use by anothe

Posted 12 October 2012 - 04:58 PM

In the property windows of the offending form, click on the dropdown and look through see if you can find ctlCustomerSelector because VS apparently has found it somewhere in that form. Maybe you inadvertently dropped it in a panel or something that's not readily visible to you.

You could also open the designer and look through it to see in what context that name already exists.

This post has been edited by CharlieMay: 12 October 2012 - 04:59 PM

Was This Post Helpful? 1
  • +
  • -

#4 Coding in the name of  Icon User is offline

  • D.I.C Head

Reputation: 67
  • View blog
  • Posts: 232
  • Joined: 07-July 10

Re: [Solved] The name '<name>' is already in use by anothe

Posted 13 October 2012 - 05:06 AM

Thanks CharlieMay, there was another control somewhere invisible on the form.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1