Structure question

  • Thread starter Thread starter Peter Lux
  • Start date Start date
P

Peter Lux

I have a structure called Stitch that has an x,y coordinate, a maincolor mc
and a secondary color, sc. I want to render these @ the x,y coordinate. I've
already done that without it being in a structure.

Public Structure Stitch
Public x As Integer
Public y As Integer
Public mc As System.Drawing.Color
Public sc As System.Drawing.Color
End Structure

What I want to do is create some sort of linked list (or array?) or some way
of collecting all the Stitches together. How do I do that? Create an array
of Stitch? Add an extra data item in the Stitch structure and keep track of
it programmatically? 'Stitch's will be added each time the user clicks in a
grid in a picture box.

I haven't worked much in VB - mostly database stuff - not drawing so I
wasn't sure if structure or class would be most appropriate.

Someone suggested a custom collection by "You should subclass the abstract
CollectionBase class which exists for people who want to implement a stongly
typed collection. " but how do you do this??
 
Peter,
What I want to do is create some sort of linked list (or array?) or some way
of collecting all the Stitches together. How do I do that? Create an array
of Stitch?

I'd recommend using an ArrayList instead, since you want to be able to
dynamically add items. But then I would also change Stitch to eb a
Class instead of a Structure to prevent boxing.

If you want a strongly typed collection you can certainly create that
too.


Mattias
 
Peter,


I'd recommend using an ArrayList instead, since you want to be able to
dynamically add items. But then I would also change Stitch to eb a
Class instead of a Structure to prevent boxing.

If you want a strongly typed collection you can certainly create that
too.


Mattias

And if you wait a few weeks and get version 2005 you get the generic
classes built in! Reason to upgrade!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top