Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Show all textbox name properties on a form...

Posted on 2009-07-07
13
Medium Priority
?
214 Views
Last Modified: 2012-05-07
Hi,

Is there a good way of showing all the name properties for a form.

What I want to do is see all the variable names... Instead of clicking each one and writing it down I was wondering if there was a built in method or a program to download.

tnx
~j
0
Comment
Question by:NCSO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24801081
Where do you want to see all the variable names ? What exactly do you mean ?

Retrieve, Change, or Create Program Information
http://visualbasic.about.com/od/usingvbnet/a/proginfo.htm
0
 
LVL 6

Expert Comment

by:ahmad2121
ID: 24801088
It's all in the designer files. Just open the designer, and look for every instance of .Name.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24801111
What do you mean with "name properties" ?
Looks like you need a PropertyGrid
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:NCSO
ID: 24803064
It was hastly put together...  here's some clarification...

I have forms with 50+ textboxes and instead of clicking each individual box and writing down the variable name it would be cool (and time-saving) if there was a way to print out the form with the property:(Name) on it.    

I printed the Document Outline which helps a bit but it still isn't what I want.

ahmad2121:  Yes I know it is, but I also have 11.000 other controls and crap on the form that makes that view slightly skewed without sorting through it.

jaime_olivares: Well I mean the Property called "Name" for the textboxes, checkboxes, dropdowns etc.  

tnx
~j
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24803220
Use LINQ and Visual Basic 2008 to Get a List of TextBoxes from a Windows Forms Form
http://cs.vbcity.com/blogs/mike-mcintyre/archive/2008/09/01/use-linq-and-visual-basic-2008-to-get-a-list-of-textboxes-from-a-windows-forms-form.aspx
' Create a LINQ query.
 
        Dim textBoxQuery = From control In Me.Controls Where TypeOf (control) Is TextField
 
        ' Create a list of object.
 
        Dim textBoxList = textBoxQuery.ToList
 
        ' Iterate through the objects in textBoxList.
        For Each txtBox As TextBox In testBoxList
            ' Show each TextBox's name property.
            MessageBox.Show(txtBox.Name)
            ' Show each TextBox's text property.
            MessageBox.Show(txtBox.Text)
 
        Next

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24803469
>>Yes I know it is, but I also have 11.000 other controls and crap on the form that makes that view slightly skewed without sorting through it.
Sound like you are not organizing well your dialog. A datagrid or propertygrid will give you similar functionality in a single control.
More than 100 controls in a form is against any UI design recommendation.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24803489
You can also do it without linq:

Dim ctrl As Control
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is TextBox Then 
                  MessageBox.Show(ctrl.Name)
        Next

Open in new window

0
 

Author Comment

by:NCSO
ID: 24803835
Jeeezzz....

jaime_olivares: Thanks for your comment on my organizational skills, if I needed a lecture I would have asked my wife's opinion...  Obviously I was exaggerating....

Dhaest:   Right, but that doesn't really do more that the Document Outline gives me...  

What I would love to see was a program or utility to print the form and overlay the variable names (in this case the Property:Name)...

I guess it's up to me to build it.

tnx
~j
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24804317
>>Thanks for your comment on my organizational skills, if I needed a lecture I would have asked my wife's opinion...
Even if you have 100 controls, my comments about thinking in another integrated control like datagrid or propertygrid is still valid. Sometimes the solution to a question is different than your initial expectation.
This kind of answers just contribute to discourage experts to continue helping you.

Besides this, there is not a property called Name, it is just simulated by VS form editor. Controls are stored as fields of form, so you can query by field name with reflection:

TextBox tb = this.GetType().GetField("FieldNameHere").GetValue(this) as TextBox;  // asumming 'this' is form itself
tb.Text = something.

So, if your information is inside a dictionary like:

Dictionary<string,string> allInfo= .....;  // key = textbox name, value=text

foreach (KeyValuePair<string,string> info in allInfo)
{
   TextBox tb = this.GetType().GetField(info.Key).GetValue(this) as TextBox;  // asumming 'this' is form itself
   if (tb != null)
   {
       tb.Text = info.Value;
   }
}
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 24806260
In what control, text, ... do you want to show all the names of the textbox ?

Example: list all names in a combobox

Dim ctrl As Control
        For Each ctrl In Me.Controls
            If TypeOf ctrl Is TextBox Then 
                  cbo.Items.Add(ctrl.Name)
        Next

Open in new window

0
 

Author Comment

by:NCSO
ID: 24806468
I must be explaining myself completely wrong I guess...  (i am a freakin' foreigner so what did you expect :)

I don't want to show the variables in the program, I would like a way to see the form with the Name property displayed by each field to ease the creation of SQL statements etc.

My ideal solution would show the Form like a screenshot perhaps and with the Property 'overlayed' on each editable control such as checkboxes, text boxes, listboxes etc.  

~j
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 24811191
Now I understand what you mean...
I don't think that there is a tool or something to achieve what  you want...
0
 

Author Closing Comment

by:NCSO
ID: 31600822
Document Outline is my only solution I guess... thanks anyway...

Enjoy the points!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question