Click here to Skip to main content
15,921,959 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Use chart control in vb.net application Pin
Robert Rohde2-Jan-05 3:31
Robert Rohde2-Jan-05 3:31 
GeneralRe: Use chart control in vb.net application Pin
Mekong River2-Jan-05 10:21
Mekong River2-Jan-05 10:21 
GeneralPretty Code in Forum Pin
OICU8121-Jan-05 13:49
OICU8121-Jan-05 13:49 
GeneralRe: Pretty Code in Forum Pin
Dennis C. Dietrich1-Jan-05 16:06
Dennis C. Dietrich1-Jan-05 16:06 
GeneralRe: Pretty Code in Forum Pin
OICU8121-Jan-05 19:40
OICU8121-Jan-05 19:40 
QuestionCan I do an event handler in a collection class to capture an event raised by one of its objects Pin
TJO11-Jan-05 1:32
TJO11-Jan-05 1:32 
AnswerRe: Can I do an event handler in a collection class to capture an event raised by one of its objects Pin
Robert Rohde1-Jan-05 1:46
Robert Rohde1-Jan-05 1:46 
AnswerRe: Can I do an event handler in a collection class to capture an event raised by one of its objects Pin
OICU8121-Jan-05 8:37
OICU8121-Jan-05 8:37 
I've been working on a similar problem and I handled it with Delegates. I made an example using your class descriptions to test my knowledge of delegates. I'm no expert here but this will do what I think you are looking for.

'The delegate that handles the communications between classes.
Public Delegate Sub AreaChangedHandler(ByVal sender As PartObject)

Public Class PartsCollection
    'simplified collection
    'not intended to demonstrate a true collection class
    Dim m_collection As New ArrayList
    Dim m_Area As Double
    Shared Event AreaChanged As AreaChangedHandler
    Public Event PartAdded(ByVal part As PartObject)
    ReadOnly Property Area() As Double
        Get
            Dim obj As PartObject
            Dim totalArea As Single
            For Each obj In m_collection
                totalArea += obj.Area
            Next
            Return totalArea
        End Get

    End Property

    Friend Sub Add(ByVal part As PartObject)
        m_collection.Add(part)
        RaiseEvent PartAdded(part)
    End Sub

    Shared Sub OnAreaChanged(ByVal sender As PartObject)
        RaiseEvent AreaChanged(sender)
    End Sub

End Class

Public Class PartObject
    Dim m_Width As Single
    Dim m_Height As Single
    'Shared delegate that invokes OnAreaChanged method in PartsCollection
    'without having to create an instance of PartsCollection
    Private Shared delegateAreaChanged As New AreaChangedHandler(AddressOf PartsCollection.OnAreaChanged)

    Property Height() As Single
        Get
            Return m_Height
        End Get
        Set(ByVal Value As Single)
            m_Height = Value
            Call AreaChanged()
        End Set
    End Property

    Property Width() As Single
        Get
            Return m_Width
        End Get
        Set(ByVal Value As Single)
            m_Width = Value
            Call AreaChanged()
        End Set
    End Property

    ReadOnly Property Area() As Single
        Get
            Return m_Height * m_Width
        End Get
    End Property

    Protected Overridable Sub AreaChanged()
        delegateAreaChanged.Invoke(Me)
    End Sub
End Class

GeneralExporting Data from Dataset/Datagrid in Excel from Win Forms Pin
Sarmad Sarosh1-Jan-05 1:22
sussSarmad Sarosh1-Jan-05 1:22 
GeneralRe: Exporting Data from Dataset/Datagrid in Excel from Win Forms Pin
Robert Rohde1-Jan-05 1:54
Robert Rohde1-Jan-05 1:54 
QuestionHow to get read of client socket information from the user command Pin
amitranjanmishra1-Jan-05 0:52
amitranjanmishra1-Jan-05 0:52 
GeneralWriting OCXs Pin
stv_no1-Jan-05 0:22
stv_no1-Jan-05 0:22 
Generalexe still running after exit Pin
jlawren7731-Dec-04 5:40
jlawren7731-Dec-04 5:40 
GeneralRe: exe still running after exit Pin
Dennis C. Dietrich31-Dec-04 7:08
Dennis C. Dietrich31-Dec-04 7:08 
GeneralRe: exe still running after exit Pin
jlawren7731-Dec-04 7:41
jlawren7731-Dec-04 7:41 
GeneralRe: exe still running after exit Pin
Dennis C. Dietrich31-Dec-04 9:13
Dennis C. Dietrich31-Dec-04 9:13 
GeneralMS Word like tables Pin
normschaef31-Dec-04 5:24
normschaef31-Dec-04 5:24 
GeneralRe: MS Word like tables Pin
Robert Rohde1-Jan-05 2:04
Robert Rohde1-Jan-05 2:04 
GeneralRe: MS Word like tables Pin
normschaef3-Jan-05 4:02
normschaef3-Jan-05 4:02 
GeneralProblem in Counter Pin
imshally8130-Dec-04 20:36
imshally8130-Dec-04 20:36 
GeneralNull value Pin
fan wei fang30-Dec-04 14:55
fan wei fang30-Dec-04 14:55 
GeneralRe: Null value Pin
spidur131-Dec-04 3:39
spidur131-Dec-04 3:39 
Generaldisabling column in databound grid Pin
besah30-Dec-04 14:50
besah30-Dec-04 14:50 
GeneralRe: disabling column in databound grid Pin
fan wei fang30-Dec-04 14:58
fan wei fang30-Dec-04 14:58 
GeneralRe: disabling column in databound grid Pin
Robert Rohde30-Dec-04 22:29
Robert Rohde30-Dec-04 22:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.