multi control naming convention

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I'm new to C# and .NET. I'm a first time user of Visual C# 2005 Express and
have a very basic question. I've looked at several links and lots of docs but
can't find any tips on naming multiple controls used for the same purpose on
different Forms.

Specifically, I have several identical TextBox controls each on a different
TabPage. The textboxes display the same variable content on each TabPage. An
example might be display of name and ssn on each page of a personnel form. Is
there a naming convention for naming each TextBox control? I assumed the
container name could be used but I see that is a no-no. Of course, txtName1,
txtName2 is possible but isn't very meaningful.

Also, I don't like to waste others time so if there is a more appropriate
forum/NG for us C# newbies, a link will be appreciated.

Thanks for the help and and Best Regards,
Sturdy
 
There is no naming convention for such a very special case which should
indeed be avoided.
If there are identical things on different tabpages make them in one
usercontrol and put that in the different tabpages.
 
Cody,

Thanks for the response...I said I was a newby. ;) I had not yet discovered
the usercontrol. Seems a much better solution once I figure out the details.

Thanks again,
Sturdy
 
Hi Cody,

Here is a good link to some coding conventions:
http://weblogs.asp.net/scottdockendorf/archive/2005/01/26/361020.aspx

What is the purpose of your form/tabpages/Application? I usually use the
name provided by visual studio for a control, i then remove the numbered
portion and replace it with some meaningul text that helps describe the
purpose of the control.

If the controls are of such a nature that meaningful information can not be
attached to it you should generate the controls dynamically to safe yourself
some effort.

If you need some examples on how to create controls dynamivcally give me a
shout!

I was pleased to discover that Visual Studio 2005 professional has the
capability to check for naming conventions & other coding best practices.

http://msdn2.microsoft.com/en-us/library/4dtdybt8(VS.80).aspx
 
Thanks for the assist...

I found and saved this link but didn't find anything to help with my
original question. Good info tho for us newbies.
What is the purpose of your form/tabpages/Application?

Basic data entry on multiple TabPages. I wanted data entered on the first
page to cascade to other pages. When I asked the question, I was concerned
about identical controls on more than one page. Clearly, I had not learned
enough to consider other means. Cody's response was helpful to get me
thinking again. But a UserControl is beyond me at this time. My final method
is to use a ComboBox bound to the DB on page one and a TextBox on other pages
with TextBox.Text = ComboBox.Text. Seems to work well and the default names
of the TextBoxes are usable since they are display only (never accessed).
I usually use the
name provided by visual studio for a control, i then remove the numbered
portion and replace it with some meaningul text that helps describe the
purpose of the control.

Won't this convention become confusing since IntelliSense will group by
object type?
If the controls are of such a nature that meaningful information can not be
attached to it you should generate the controls dynamically to safe yourself
some effort.

If you need some examples on how to create controls dynamivcally give me a
shout!

I was pleased to discover that Visual Studio 2005 professional has the
capability to check for naming conventions & other coding best practices.

http://msdn2.microsoft.com/en-us/library/4dtdybt8(VS.80).aspx
thanks

I have lots of opportunity ;)


Thanks again,
Sturdy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top