Wiki Home

Super Moverclass

Namespace: VB
I need to create a mover that will move multiple columns.
Like the base mover, but it would move 2 columns to another list box with 2 columns. I don't want to concatenate the two fields, as I do not want to show one of them.

I've tried working with acopy, etc. but I just can't get it to work.

Any ideas?

A code sample in the right direction would be great...


Some Thoughts

As you may know, a Listbox or Combobox has the two dimensional array property for data: List[row, column]. When you fill a listbox, you specify the size (rows and columns) of this List property simply by assigning values to row/column combinations - no DIMENSION statement necessary.

From a visibility standpoint, after loading two columns of data for each row in the List[row, column] property, you can specify the ColumnCount property to be 1 and the BoundColumn property to be 2. This will show column 1 but hide column 2 even though you are bound to column 2.

To copy from one list box to the other you copy each element of the List property - I don't believe ACOPY works in this scenario:

* This example would be called from a form method
Local x
With Thisform.listbox1
  For x = 1 to thisform.listbox2.listcount
    .List[m.x, 1] = thisform.listbox2.List[m.x, 1]
    .List[m.x, 2] = thisform.listbox2.List[m.x, 2]

The above example simple copies the whole list, if you need to insert a few rows from one to the other, you would copy the first value using LISTBOX.ADDITEM and then additional columns using an assignment to the List property:

* This example would be called from a form method.  It copies currently selected listbox2
* items from listbox2 to the end of the list in listbox1.
Local x
With Thisform.listbox1
  For x = 1 to thisform.listbox2.listcount
    If thisform.listbox2.selected(m.x)
      .AddItem(thisform.listbox2.List[m.x, 1], .listcount + 1, 1)
      .List[.listcount, 2] = thisform.listbox2.List[m.x, 2]

Ben Creighton
( Topic last updated: 2012.09.08 08:16:00 AM )