Solved

How can I add a variable to a 3rd party class?

Posted on 2008-10-10
4
200 Views
Last Modified: 2010-04-21
I am using Dundas chart class. It is in a DLL so I dont have direct access to it. Everything works great, but there is a  situation that I am having a hard time going around:
I am handling the mouse click event for several charts in my program.  All events are handled by the same function, which in turn calls another function that takes an enum type as a parameter.
Right now I am using an If/Else block that uses the chart titles to define what is the enum that that each chart should be assigned to.
Ideally I would like to use some kind of inheritance to be able to identify each chart directly by an enum that is defined as a member variable.
Private Sub Charts_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseClick, Chart2.MouseClick, Chart3.MouseClick
        ' Call Hit Test Method
        Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)
 
        If result.ChartElementType = ChartElementType.DataPoint Then
            Dim frmTest As New DrillDownWindow
            'This is what I would like to do, but I cant beacause enumChartType is not a defined memeber in Dundas Chart class
            frmTest.GenerateData(sender.enumChartType)
 
            frmTest.Show()
            frmTest.BringToFront()
        End If

Open in new window

0
Comment
Question by:aferia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:lludden
ID: 22691051
Can't you use the .tag on each chart object to store the relevant information?

If you want something more type safe, then inherit the control and add whatever fields you want to it.
0
 

Author Comment

by:aferia
ID: 22691144
The problem with inheriting the control is that I loose the advatage of being able to setup the chart using the form designer. Dundas charts can be manipulated from the form designer and they have a very good wizard that can only be accessed from the form designer.
I dont what .tag is, can u expand a little?
0
 
LVL 18

Accepted Solution

by:
lludden earned 500 total points
ID: 22691716
tag is an object that is added to most controls.  It is generally not used for anything by the control, but since it is a type object, the user can assign anything to it.

I have used it heavily when building forms dynamically to keep track of what data is in each control.  Here's an example.  I have a Manager inherits from employee, but also has a list of employees that person manages.  I needed to display on a form a series of listboxes, one for each manager, with all the employees listed in each.  Since I didn't know how many managers there would be at any given time, I added the listboxes dynamically at run time.  So I would know which was clicked on, I did lb(i).tag = manager(i) tying the manager to each listbox object.  Then in my event, I could do:

Ctype(CType(sender,Listbox).Tag,Manager).Name to get the manager name or whatever property of the manager object I needed.
0
 

Author Closing Comment

by:aferia
ID: 31505205
Great! That was exactly what I needed... it worked like a charm!
Thank you very much!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question