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

hmmm... Is this possible?

I have a base class that is derived from an existing class and i need to
have ANOTHER class that is linked to the objects created in their
class. OK icant explain it properly. Here is part of the code.

Ok i assume you have read the code by now. So, without creating a new
dictionary and running the same keys with different objects as the
values. How else can i make it so when i .Add in DictinaryDraw, that i
can access the properties and methods individually for each object in
the dictionary? In other words i need a new instance of the reference
(for properties and methods) to be accessable via the object within the
dictionary. so something like this
dictionarydraw(index).referenceproperty. I understand i probably need to
inherit drawreference into the object im adding into the dictionary,
except i cant because its a system class.
Imports System.Collections
Public Class DictionaryDraw
Inherits DictionaryBase

Private indexLast As Integer = -1

Public Function Add() As Integer
Do While MyBase.Dictionary.Contains(indexLast)
indexLast = indexLast + 1
Loop
MyBase.Dictionary.Add(indexLast + 1, New Drawing2D.GraphicsPath())
End Function

End Class
Public Class DrawReference

#Region "Declarations"
'All my declarations in here
#End Region

#Region "Properties"
'All my properties in here
#End Region

End Class
Nov 21 '05 #1
3 883
"Matt" <ma*****@interactiveideasandsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
So, without creating a new dictionary and running the same keys
with different objects as the values. How else can i make it so when
i .Add in DictionaryDraw, that i can access the properties and
methods individually for each object in the dictionary?


Each item in the Dictionary is a DictionaryEntry, each of which has
a Key and a Value property, the latter being the object that you
added. You'd have to know (or be prepared to find out) what
Type it is, and then you can "down-cast" it to the correct Type so
you can use it, as in

Dim x as New DictionaryDraw
Dim y as Drawing2D.GraphicsPath()

y = DirectCast( _
x.Item( "abc" ).Value _
, Drawing2D.GraphicsPath() _
)
MsgBox( y.SomeProperty )

Also,

Do While MyBase.Dictionary.Contains(indexLast)
indexLast = indexLast + 1
Loop
MyBase.Dictionary.Add(indexLast + 1, ...

Could be replaced by

' I /think/ it's .Count; /might/ be .Length ...
MyBase.Dictionary.Add( MyBase.Dictionary.Count + 1 )

HTH,
Phill W.
Nov 21 '05 #2
Thanks Phil. But i was meaning the "extra" properties i want to assign
to the object in the dictionary value. For instance, all the properties
in the class DrawReference to be accessable by each new object instance
in the directionary. The class is already stronly typed so i dont have
to directcast all the time. Since its going to be a pretty cpu intensive
program for those few seconds every time a graphic is loaded.

I cant replace indexlast+1 with .count+1 because my index's are going to
be individually deleted and added frequently. So the highest index most
probably always will not be the same number as .count

Thanks for the reply though. Its good to see someone read my post :)
Phill. W wrote:
"Matt" <ma*****@interactiveideasandsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
So, without creating a new dictionary and running the same keys
with different objects as the values. How else can i make it so when
i .Add in DictionaryDraw, that i can access the properties and
methods individually for each object in the dictionary?

Each item in the Dictionary is a DictionaryEntry, each of which has
a Key and a Value property, the latter being the object that you
added. You'd have to know (or be prepared to find out) what
Type it is, and then you can "down-cast" it to the correct Type so
you can use it, as in

Dim x as New DictionaryDraw
Dim y as Drawing2D.GraphicsPath()

y = DirectCast( _
x.Item( "abc" ).Value _
, Drawing2D.GraphicsPath() _
)
MsgBox( y.SomeProperty )

Also,

Do While MyBase.Dictionary.Contains(indexLast)
indexLast = indexLast + 1
Loop
MyBase.Dictionary.Add(indexLast + 1, ...

Could be replaced by

' I /think/ it's .Count; /might/ be .Length ...
MyBase.Dictionary.Add( MyBase.Dictionary.Count + 1 )

HTH,
Phill W.

Nov 21 '05 #3
NEVERMIND! i ask stupid questions. I figured out a way to do it that
satisfy's my need. besides, i dont think what i was asking is possible
anyway coz its kinda obscure.

Matt wrote:
I have a base class that is derived from an existing class and i need to
have ANOTHER class that is linked to the objects created in their
class. OK icant explain it properly. Here is part of the code.

Ok i assume you have read the code by now. So, without creating a new
dictionary and running the same keys with different objects as the
values. How else can i make it so when i .Add in DictinaryDraw, that i
can access the properties and methods individually for each object in
the dictionary? In other words i need a new instance of the reference
(for properties and methods) to be accessable via the object within the
dictionary. so something like this
dictionarydraw(index).referenceproperty. I understand i probably need to
inherit drawreference into the object im adding into the dictionary,
except i cant because its a system class.
Imports System.Collections
Public Class DictionaryDraw
Inherits DictionaryBase

Private indexLast As Integer = -1

Public Function Add() As Integer
Do While MyBase.Dictionary.Contains(indexLast)
indexLast = indexLast + 1
Loop
MyBase.Dictionary.Add(indexLast + 1, New Drawing2D.GraphicsPath())
End Function

End Class
Public Class DrawReference

#Region "Declarations"
'All my declarations in here
#End Region

#Region "Properties"
'All my properties in here
#End Region

End Class

Nov 21 '05 #4

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

Similar topics

4
by: Hal Davison | last post by:
I have an application that uses a TreeView for an interactive menu function with its elements being populated from a database. In the KEY component of the TreeView I put the acutal name of the...
19
by: JKop | last post by:
Been thinking about the following: class Mammal { public: virtual void Mate(Mammal &) = 0; };
2
by: Mike MacSween | last post by:
How do I create a shortcut on a users desktop if I can't log on as that user? TIA, Mike MacSween
67
by: Serve La | last post by:
I asked if MS has any plans to support C99 in the next VisualC. This is their answer. I think we should whine more :-) We feel that C++ addresses this space sufficiently. In general we have no...
35
by: Stan Milam | last post by:
The following code implements a strcat-like function which can receive a variable number of arguments. I thought it would be faster if I kept a pointer to the end of the string as it is built so...
30
by: Tibby | last post by:
Okay, I've made my DLL with COM interop so it can be used with VB6, and it works like a charm, my question is, how do I register it and it's .tlb file on another computer so I can use it there? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.