|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
two-dimensional arraysI've chosen to store the contents of a grid in a two dimensional object
array. As the size of the grid changes, so must the array. I was surprised to find out that the niceties I'm used to with one dimensional arrays are just not there with more dimensions. No ReDim (except for the rightmost dimension), no CopyTo. Now for resizing I can get around this with my own loops, but I was wondering if I wasn't missing something... more built in (and therefore probably faster) for multi-dimensional array resizing. Paul Hi Paul,
in a similar situation I have found to be more convenient and efficient to work with an ArrayList of Objects(). You might consider this option as well. Vb does not seem to give its best with multidimensional structures... let's see some other opinions about that ... -tom PJ6 ha scritto: Show quoteHide quote > I've chosen to store the contents of a grid in a two dimensional object > array. As the size of the grid changes, so must the array. I was surprised > to find out that the niceties I'm used to with one dimensional arrays are > just not there with more dimensions. No ReDim (except for the rightmost > dimension), no CopyTo. Now for resizing I can get around this with my own > loops, but I was wondering if I wasn't missing something... more built in > (and therefore probably faster) for multi-dimensional array resizing. > > Paul Paul,
Microsoft has made around the standard (Data)Grids the most sophisticated OO classes. They all are in the system.data namespace. For what you write I would first have a look at the DataTable. You can make them by code. Our website is full of samples which start with this. Here a very simple one http://www.vb-tips.com/default.aspx?ID=65a5ae57-d41c-4144-b9f9-d0e5d6bcb7e2 I hope this helps, Cor Show quoteHide quote "PJ6" <no***@nowhere.net> schreef in bericht news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl... > I've chosen to store the contents of a grid in a two dimensional object > array. As the size of the grid changes, so must the array. I was surprised > to find out that the niceties I'm used to with one dimensional arrays are > just not there with more dimensions. No ReDim (except for the rightmost > dimension), no CopyTo. Now for resizing I can get around this with my own > loops, but I was wondering if I wasn't missing something... more built in > (and therefore probably faster) for multi-dimensional array resizing. > > Paul > Hmmm. Well I guess I can use the DataTable, though I'll be using my own row
and column collections. Yes, that works rather nicely. Thanks, Paul Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OpsO29EjGHA.5020@TK2MSFTNGP02.phx.gbl... > Paul, > > Microsoft has made around the standard (Data)Grids the most sophisticated > OO classes. > > They all are in the system.data namespace. > > For what you write I would first have a look at the DataTable. > You can make them by code. > > Our website is full of samples which start with this. > > Here a very simple one > > http://www.vb-tips.com/default.aspx?ID=65a5ae57-d41c-4144-b9f9-d0e5d6bcb7e2 > > I hope this helps, > > Cor > > "PJ6" <no***@nowhere.net> schreef in bericht > news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl... >> I've chosen to store the contents of a grid in a two dimensional object >> array. As the size of the grid changes, so must the array. I was >> surprised to find out that the niceties I'm used to with one dimensional >> arrays are just not there with more dimensions. No ReDim (except for the >> rightmost dimension), no CopyTo. Now for resizing I can get around this >> with my own loops, but I was wondering if I wasn't missing something... >> more built in (and therefore probably faster) for multi-dimensional array >> resizing. >> >> Paul >> > > Instead of a 2 dimensional array you might investigate Jagged Arrays
a big advantage is that you can use redim preserve and they are up to five or six times faster as a multidimensional array can you inmagine how much faster it will be as a datatable :-) regards Michel Posseth [MCP] Show quoteHide quote "PJ6" <no***@nowhere.net> schreef in bericht news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl... > I've chosen to store the contents of a grid in a two dimensional object > array. As the size of the grid changes, so must the array. I was surprised > to find out that the niceties I'm used to with one dimensional arrays are > just not there with more dimensions. No ReDim (except for the rightmost > dimension), no CopyTo. Now for resizing I can get around this with my own > loops, but I was wondering if I wasn't missing something... more built in > (and therefore probably faster) for multi-dimensional array resizing. > > Paul > Hmmm...
Private MyTable As New Collections.Generic.Dictionary(Of Row, Collections.Generic.Dictionary(Of Column, Cell)) Well that works. I don't know if it performs faster but the housekeeping isn't too bad for add and remove rows and columns and it's strongly typed. Yeah I like that better. Thanks for the suggestion. Paul Show quoteHide quote "Michel Posseth [MCP]" <mic***@posseth.com> wrote in message news:eFzLR3XjGHA.4040@TK2MSFTNGP05.phx.gbl... > > Instead of a 2 dimensional array you might investigate Jagged Arrays > > a big advantage is that you can use redim preserve and they are up to five > or six times faster as a multidimensional array > can you inmagine how much faster it will be as a datatable :-) > > regards > > Michel Posseth [MCP] > > > > > "PJ6" <no***@nowhere.net> schreef in bericht > news:eDh4xKCjGHA.4304@TK2MSFTNGP03.phx.gbl... >> I've chosen to store the contents of a grid in a two dimensional object >> array. As the size of the grid changes, so must the array. I was >> surprised to find out that the niceties I'm used to with one dimensional >> arrays are just not there with more dimensions. No ReDim (except for the >> rightmost dimension), no CopyTo. Now for resizing I can get around this >> with my own loops, but I was wondering if I wasn't missing something... >> more built in (and therefore probably faster) for multi-dimensional array >> resizing. >> >> Paul >> > >
ASCII Character code for the 6th power
Lost my Design view for a Windows Form (VB 2005) Is there a built in command to encode SQL strings? Last Modified date for the Source code. Launch new instance of IE?? GraphicsPath.IsVisible broken? text file to datatable to SQL2005 table not working Placeholder Object Question VB.NET/2005 Application crash Delete a DataSource in vs.net |
|||||||||||||||||||||||