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 / Windows Forms / WinForm Controls / March 2008

Tip: Looking for answers? Try searching our database.

Control.Name property is blank ("")

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Justin Roberts - 17 Mar 2008 16:14 GMT
Hi.

I am using VB.Net in VS 2005,
I was wondering if anyone knows how I can retreive the actual control.name
when using the controls collection.

E.g. In the given example, (where v_parent is a toolstripcontainer),
ctrl.Name is always "" even though the debugger clearly recognises it as a
toolstrip panel control.

Private Sub TestControlNames(ByVal v_parent As Control)
If Not v_parent Is Nothing Then
        For Each ctrl As Control In v_parent.Controls
           If TypeOf (ctrl) Is ToolStripPanel Then
              MsgBox(ctrl.Name)
           End If
End If
End Sub

Is there a better VB.Net way of iterating through form controls, that would
give me the control.name properties. I'm still completely confused as to why
the name would be "" in the first place, VB.Net must know what it is?

Any help much appreciated.
Thank you
Regards
Justin Roberts - 17 Mar 2008 17:32 GMT
Never mind.. I figured out what the problem is.

It appears that ToolStripPanels do not have their control name assigned at
design time. In the IDE, ToolStripPanels have a name and can 'renamed' there,
however the name will never appear in the form.designer.vb module unless it
is manually entered there. Without a name in the form.designer.vb module, the
name property is blank at run-time.

Regards
Morten Wennevik [C# MVP] - 18 Mar 2008 07:16 GMT
Hi Justin,

The Name property is optional.  In fact, the IDE doesn't display the Name
property of the control, but rather the programmatic (Name) used in code.  
These do not have to be the same, but to avoid confusion, the Name property
is hidden in the IDE, and any change to the (Name) will update Name as well.  
As for ToolStripPanel.Name not being set by the IDE, that may well be a bug,
but I could not reproduce this bug as in my VS2005 C# project it did get its
Name set by the IDE.

Signature

Happy Coding!
Morten Wennevik [C# MVP]

> Never mind.. I figured out what the problem is.
>
[quoted text clipped - 5 lines]
>
> Regards

Rate this thread:







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.