Search code examples
axaptadynamics-ax-2012x++

How to "set" a selected item in a ListView


I'm working with ListView controls and have the need to set which item is currently selected, as opposed to getting the current selected item. I've done a lot of reading and don't seem to be finding how one can do this using code.


Solution

  • Yep, Sir Troll you led me to the answer. It is done by modifying the FormListItem object instead of the ListView itself. FormListItem.stateSelected(true) will make the item be marked as selected. I tried marking it selected after it has been added to the ListView and it did not work, it must be done before adding it to the ListView. However, I haven't tried this, but I suspect it should work if you utilize the ListView.setItem(...) method.