473,320 Members | 1,965 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.

control name

I want to dynamically get the control from the event being executed at a
particular time. For example, lets say I have the following event.
combobox1_SelectedIndexChanged((ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles combobox1.SelectedIndexChanged

I don't want to just specify combobox1. I need to dynamically get the
control from the eventsender or some other method so I can write a generic
function used for any control without having to specify the actual controls
like comboBox1 or ComboBox2.

I would really appreciate someone telling me how to do it.

Thanks
Mar 9 '07 #1
4 973

Nevermind, I figured out I could just say the following:

dim x as object
x=eventsender

I was trying to use the eventsender.gettype.SOMETHING and didn't realize
just setting x = to eventsender would give me everything I was after.

Thanks
"John" wrote:
I want to dynamically get the control from the event being executed at a
particular time. For example, lets say I have the following event.
combobox1_SelectedIndexChanged((ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles combobox1.SelectedIndexChanged

I don't want to just specify combobox1. I need to dynamically get the
control from the eventsender or some other method so I can write a generic
function used for any control without having to specify the actual controls
like comboBox1 or ComboBox2.

I would really appreciate someone telling me how to do it.

Thanks
Mar 9 '07 #2
On Mar 9, 10:21 am, John <J...@discussions.microsoft.comwrote:
Nevermind, I figured out I could just say the following:

dim x as object
x=eventsender

I was trying to use the eventsender.gettype.SOMETHING and didn't realize
just setting x = to eventsender would give me everything I was after.

Thanks

"John" wrote:
I want to dynamically get the control from the event being executed at a
particular time. For example, lets say I have the following event.
combobox1_SelectedIndexChanged((ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles combobox1.SelectedIndexChanged
I don't want to just specify combobox1. I need to dynamically get the
control from the eventsender or some other method so I can write a generic
function used for any control without having to specify the actual controls
like comboBox1 or ComboBox2.
I would really appreciate someone telling me how to do it.
Thanks
Note that you can also cast the sender into a certain type instead of
just leaving it as an object:

i.e.

private sub combobox_SomeEvent(sender as object, e as eventargs)
if (sender is Combobox)
Dim cbo as ComboBox = DirectCast(sender, combobox)
' Do combobox specific stuff here
else if (sender is TextBox)
Dim tb as TextBox = DirectCast(sender, textbox)
' Do textbox specific stuff here
end if
end sub

Thanks,

Seth Rowe

Mar 9 '07 #3
"rowe_newsgroups" <ro********@yahoo.comschrieb:
[...]
if (sender is Combobox)
='If TypeOf sender Is ComboBox Then'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Mar 9 '07 #4
On Mar 9, 1:08 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.atwrote:
"rowe_newsgroups" <rowe_em...@yahoo.comschrieb:
[...]
if (sender is Combobox)

='If TypeOf sender Is ComboBox Then'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
To much C# lately :-)

Thanks,

Seth Rowe

Mar 9 '07 #5

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

Similar topics

0
by: Miguel Guerreiro | last post by:
I have an ActiveX Control that I am trying to make work from an ASP page, but so far all I got is great frustation! My Control is well registered (and working fine from a VB stand-alone program I...
8
by: deko | last post by:
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties. First, I have a record set with the...
6
by: chxant | last post by:
Hi, I want to use a parameter in a control name. Something like this: i=1; (CheckBox + i).ID="test"; Is this possible?
2
by: Merlin | last post by:
Hi I have a control that allows embeddable editors, so for example I can set a property of controlsEmbeddableEditor =me.TextBox1 on my form, no problem here - what I want to do is the same thing...
3
by: B-Dog | last post by:
I'm capturing the checked radio button to XML file using the name of the radio button. I want to read my xml file to find which button was checked on close and the check the appropriate button...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
1
by: tony | last post by:
Hello! I just want to find out how the system find the name to set on a assembly User control dll. I have done this. 1. Create a user control - Here the namespace was set by the system to...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
3
by: dcassar | last post by:
I am working on a complex server control that dynamically creates an HtmlInputHidden control that stores its value. As far as the postback process is concerned, this hidden input acts as the...
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm new to Visual Studio 2005. I'm creating a windows application using Visual Basic. After I added a control to a form and added some codings to the control, I want to rename the control. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
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...

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.