473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

naming controls

Hi,

i am a beginner to vb.net and wanted to know how i can
use the same control with the same name and function in
the same form.

I.e if i want to have 4 save buttons on the same form and
name the the same........ is this poss. i dont wanna keep
coming up with new names for buttons that do the same
thing.

thx
Jul 21 '05 #1
3 1197
Hi,

Since each button will be a separate instance of the Button class, and each
instance presumably have scope within the form you will have to give each
button a different name.

Hope this helps

Chris Taylor
"Tonya" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi,

i am a beginner to vb.net and wanted to know how i can
use the same control with the same name and function in
the same form.

I.e if i want to have 4 save buttons on the same form and
name the the same........ is this poss. i dont wanna keep
coming up with new names for buttons that do the same
thing.

thx

Jul 21 '05 #2
You have to use different names, but you can at least use the same event
handlers.

cmdSave.Click += new System.EventHandler(Save_Click);
mnuSave.Click += new System.EventHandler(Save_Click);

Sorry for the C#.

HTH;
Eric Cadwell
http://www.origincontrols.com
Jul 21 '05 #3
Hi,
You can NOT use the same name on more than one control in
the same form. Yes, you can use the same event procedures
for multiple controls. There are more than one way to do
this. I will give you the easiest approach:
1. Put code in the event procedure (I suspect you are
using the Click event) that you want for one of the
controls.
2. For all controls that are to use the same code, you
can add on the control and event name in the handles
clause of the event procedure:

Private Sub cmdSave_Click(byVal Sender as Object, ByVal e
as system.eventargs) handles cmdSave.Click,
cmdSave2.Click, cmdSave3.Click

In the above sample, the event procedure will run when the
click event occurs for all three controls.

Now, if you have some differences in code based on which
control actually received the event, you will need to
check the Sender object to examine which control and then
do the appropriate action that is specific to the actual
control that received the event. I suspect you do not
need to apply this code as yet. If you do, ask, and you
will receive.

I hope this helps. My email address has only 2 "k"s in
it. Carol

-----Original Message-----
You have to use different names, but you can at least use the same eventhandlers.

cmdSave.Click += new System.EventHandler(Save_Click);
mnuSave.Click += new System.EventHandler(Save_Click);

Sorry for the C#.

HTH;
Eric Cadwell
http://www.origincontrols.com
.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Patrick Kristiansen | last post by:
Hello group! If a company is called for examle ABC, what would be the best practice for naming a namespace. Which one of the following is preferred according to Microsoft guidelines: ...
1
by: Lalit | last post by:
Hi Friends, We are defining coding standards for our company. In MSDN i have seen that hungarian notation will not be used in naming of variables etc. What about the controls ? Should we...
4
by: Mark Broadbent | last post by:
stupid question time again to most of you experts but this is something that continually bothers me. I am trying to get into the habit of naming variables and controls in an assembly as per...
4
by: =B= | last post by:
Hi, I was wondering if anyone has any opinions on naming conventions for ASP.NET objects? Up until now I've been using txtThis for Text Boxes, ddlThat for DropDownList, etc because I think it...
2
by: Nikolay Anestev | last post by:
Hi all. I have the following problem: In an ASP.NET (C#) application i wrote some client-side script which works with some of the page controls. When the page content is rendered i see that some of...
4
by: Patrick | last post by:
what are the general naming conventions for vb.net controls. esp txtUserName, lblPassword, btnSubmit What are the prefixes for the controls???? I've tried to search hi and low on the net, but...
9
by: kevininstructor | last post by:
Greetings, I am in the process of creating naming conventions for VB.NET controls i.e. CheckBox -> chkShowThisOnStartup ListBoxt -> lstSomeList What I am looking for other developers...
4
by: Sturdy | last post by:
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...
3
by: catharticmomentusenet | last post by:
I apologise because I am aware there have already been a large number of posts on this topic, but I couldn't find one making precisely the points I wanted to make :-) I am a senior developer at...
3
by: Nathan Sokalski | last post by:
I have written a custom control that uses AJAX (it implements IPostBackDataHandler and ICallbackEventHandler). I have tested it, and it seems to work the way I want. However, when I used it in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.