473,327 Members | 2,012 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,327 software developers and data experts.

Events and List(Of ...)

Hello!

I wrote a class "Layers" with one event "DataChanged":

Public Class Layers

Private _Value as Object

Public Property Value() As Object
Get
Return _Value
End Get
Set(ByVal value As Object)
_Value = value
RaiseEvent DataChanged()
End Set
End Property

Public Event DataChanged()

End Class

I use it into another class:

Public Class Gauge

Private WithEvents _Layer As New List(Of Layers)

Public Property Layer() As List(Of Layers)
Get
Return _Layer
End Get
Set(ByVal value As List(Of Layers))
_Layer = value
End Set
End Property

Private Sub _DataChanged() Handles _Layer. <------- I'd
like .DataChanged
Draw()
End Sub
End Class
I'd like to handle in _DataChanged() the DataChanged event raised by
any Layer class into _Layer list.
But VB hide me the event after Hanldes _Layer.

Why? How may I fix this?

Note: if I declare _Layer as new Layers (without the List(Of ...)) all
works fine.

Thank you
Marco / iw2nzm

Mar 21 '07 #1
2 1152
On Mar 21, 8:06 am, marcotrapan...@gmail.com wrote:
Hello!

I wrote a class "Layers" with one event "DataChanged":

Public Class Layers

Private _Value as Object

Public Property Value() As Object
Get
Return _Value
End Get
Set(ByVal value As Object)
_Value = value
RaiseEvent DataChanged()
End Set
End Property

Public Event DataChanged()

End Class

I use it into another class:

Public Class Gauge

Private WithEvents _Layer As New List(Of Layers)

Public Property Layer() As List(Of Layers)
Get
Return _Layer
End Get
Set(ByVal value As List(Of Layers))
_Layer = value
End Set
End Property

Private Sub _DataChanged() Handles _Layer. <------- I'd
like .DataChanged
Draw()
End Sub
End Class

I'd like to handle in _DataChanged() the DataChanged event raised by
any Layer class into _Layer list.
But VB hide me the event after Hanldes _Layer.

Why? How may I fix this?

Note: if I declare _Layer as new Layers (without the List(Of ...)) all
works fine.

Thank you
Marco / iw2nzm
You need to include the NEW keyword when declaring your Layers object,
otherwise change your class to have a static(shared) event handler
like so

Public Shared Event DataChanged()

If you use a static event, you may have to wire the event handler
manually instead of using the Handles keyword by using addhandler
somewhere in your code, perhaps a forms Load event

AddHandler Layers.DataChanged, AddressOf _DataChanged()


Mar 21 '07 #2
You need to include the NEW keyword when declaring your Layers object,
mmm... I'm not sure I understand: as you can see above I declared it
in this way:
Private WithEvents _Layer As New List(Of Layers)
The NEW keyword is present. Where should I use it?
otherwise change your class to have a static(shared) event handler
like so

Public Shared Event DataChanged()

If you use a static event, you may have to wire the event handler
manually instead of using the Handles keyword by using addhandler
somewhere in your code, perhaps a forms Load event

AddHandler Layers.DataChanged, AddressOf _DataChanged()
Ok, now works fine! Thanks

Marco / iw2nzm
Mar 21 '07 #3

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

Similar topics

7
by: Klaus Neuner | last post by:
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = print string_list2regexes(string_list) This should return something like:
2
by: PA | last post by:
Hi, Can anyone tell me how to capture events of iframes like keypress. I have an editable iframe. When I hit <enter> it actually prints <p> instead of <br>. (innerHTML) Does anyone know how...
2
by: Dan | last post by:
I am having a problem trying to assign event handlers to the events of a remoted object. I have one program that registers the object for remoting, Another that connects and calls methods on the...
1
by: Lalit | last post by:
Hi, My application has two methods which creates buttons at runtime. In one method I am able to handle the events of the buttons created at run time, but in other I am not. The code structure...
6
by: Tekkaman | last post by:
I have a list of lists and I want to define an iterator (let's call that uniter) over all unique elements, in any order. For example, calling: sorted(uniter(, , ])) must return . I tried the...
0
by: aekta | last post by:
Hello, How to handle events of UserControl( containing dropdownlist in .ascx page) from .aspx page?I am loading control on some button click on .aspx with LoadControl() method dynamically.I...
1
by: Klaus Jensen | last post by:
Subject: Handling events of controls created at runtime I need to render some buttons at runtime based on a database, tie events to them, and handle the events when they fire. In Page_Load I...
14
by: xoozlez | last post by:
Hi there, I have a registration form where I like to filter out the past events of 2007. This is the code I am using : strSQL = "SELECT EventID, EventName, EventDateBegin, EventDateEnd,...
0
by: vtelebyteM | last post by:
i have 1)User control with one MSFlexGrid on it 2)Form to place user control 3)Some form's own control i dont know how many controls are there under form i have to place them in grid columns...
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...
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...
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
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.