473,320 Members | 2,104 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,320 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 1196
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.