ListView Move up/down coding

Can someone please show the proper way to use buttons to move up/down in a ListView control AND save the contents of the index to a table?

I have 2 ListView controls – one for available values and one for selected values. When values are selected, the index of the selected element is inserted into a table for use in re-displaying later. I have code in the clicked method of the up/down buttons which works fine but is not saving the changes because no insert is done. One caveat, the index of the selected element is an index on the table it is written to if that has any effect on re-arranging the elements.

int i = ListSelected.getNextItem(FormListNext::Selected);

ListSelected.moveItem(i, i-1); // or (i, i+1)

Steve

I probably wouldn’t use a ListView. I’d use a table with a linenum. Have line 0 be your “temp” line for switching if you want to keep your index valid. Some good code to look at would be:

Tables\SysImportFormatTransformation\moveUp and

Forms\SysImportFormatTransformation (MoveUp, MoveDown, etc)

I take it you pulled your code from http://dynamicsaxgyan.wordpress.com/2010/12/15/listviews-in-dynamics-ax/ or something. If you need to use a listview, I’d probably store the data in a container. An easy way would be to create an array class (http://msdn.microsoft.com/en-us/library/aa608508.aspx) and then when you want to save it, fill that class up, then do your array.pack and store it in a container somewhere. When you want to access it, just do Array::Create(_container) and you can unpack it.

Hi, Check below link

http://theaxapta.blogspot.in/2013/02/list-view-control-in-dynamics-ax.html