473,503 Members | 10,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Option strict on and detecting a listview Name

Hi. I'm probably attempting the impossible but what the hey.

I'm modifying a multi-paneled form which has 8 different listviews, To
allow sorting by columns I've had to add a diffrerent handler Sub for
each of them eg.

Private Sub ListViewOne(ByVal o As Object, ByVal e As
ColumnClickEventArgs)
...
End sub

If I could somehow detect the o.Name property of the sender object I
could identify the ListView and make the Sub handle all 8 of the
ListViews.

However because "Option Strict On" disallows late binding, I can't find
a way of accessing the properties of the sending object.

PS: I'm adding the handler to each listview as I populate them with
"AddHandler"

Any polite ideas ?

Apr 21 '06 #1
2 1203
hmmm Searched for ages for an answer so as luck would have it, I found
an answer 10 minutes after my post :-)

The solution:

If DirectCast(o, Control).Name = "ListViewOne" Then
MsgBox("Yep, this is ListViewOne")
End If

A big thank you for the solution goes to :
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/

Who answered a similar question.

Apr 21 '06 #2
James wrote:
Private Sub ListViewOne(ByVal o As Object, ByVal e As
ColumnClickEventArgs)
...
End sub

If I could somehow detect the o.Name property of the sender object I
could identify the ListView and make the Sub handle all 8 of the
ListViews.


Or, better still, because you might rename one of the ListView controls
later on and forget to change this routine, how about

Private Sub AnyListView_ColumnClick( _
ByVal sender as Object _
, ByVal e as ColumnClickEventArgs _
)

If sender Is ListView1 Then
...
ElseIf sender Is ListView2 Then
...
End If

End Sub

Or, if you don't need to /differentiate/ between them (i.e. you want all
the ListViews to do the /same/ thing when you click on them

Private Sub AnyListView_ColumnClick( _
ByVal sender as Object _
, ByVal e as ColumnClickEventArgs _
)

If TypeOf sender Is ListView Then
With DirectCast( sender, ListView )
...
End With
End If

End Sub

HTH,
Phill W.
Apr 21 '06 #3

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

Similar topics

9
2121
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
1
1623
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I...
11
2096
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
8
1810
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
30
1820
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
4
3002
by: Howard Kaikow | last post by:
I am trying to retrive some WMI properties using Option Strict On. This requires the use of InvokeMember. I know that there are alternative ways to get the values, but I want to learn how to...
17
4462
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
8
2410
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
3
4929
by: Dilip | last post by:
I inherited an owner drawn control that subclasses the Windows Forms ListView control to provide additional functionalities. I wanted to detect the presence of the Vertical scrollbar so that I can...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.