List Box OnInitialize select item in list

Started by Jim Short, March 08, 2009, 02:43:15 PM

Previous topic - Next topic

Jim Short

Can't get first item in the list to be selected during initialize.
is this possible to do?

(defun c:Onset_StandardFeatures_OnInitialize (/)
   (dcl_Control_SetEnabled Onset_StandardFeatures_btnOK False)
   (dcl_Control_SetList Onset_StandardFeatures_lstFeatures (tcam:stdFeatures))
   (dcl_ListBox_SetFocusIndex Onset_StandardFeatures_lstFeatures 0)
   (dcl_ListBox_SelectItem Onset_StandardFeatures_lstFeatures 0)
)
Jim Short

Fred Tomke

Did you have a try with SetCurSel method insteand of SelectItem?

In ancient times SetCurSel was described for using in ListBoxes with SingleSelectionStyle and SelectItem for MultiSelectionStyle. I had a look at the new documentation, there's no word about this difference.

@Owen: Does this difference still exist? Should we add this to the documentation then?

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Yes, SelectItem only works if multiple selection is enabled. I also see in MSDN that passing -1 for the ItemIndex applies it to all items.

I will add the following to the end of the descriptions for ListBox_SelectItem, ListBox_SelItemRange, DWGList_SelectItem, and DWGList_SelItemRange:
This method does not work for single-selection lists (see SelectionStyle).

For ListBox_SelectItem and DWGList_SelectItem, I will add the following after the first sentence:
If ItemIndex is -1, all list items are selected or deselected.

owenwengerd

Interestingly, it looks like ListView_SetCurSel and BlockList_SetCurSel have semantically the same behavior as ListBox_SelectItem. It seems to me that SetCurSel should be removed for all of them, and replaced with a single SelectItem that handles both multiple and single selection cases. SelectItem sounds more unambiguous to me.

Fred Tomke

Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Jim Short

Jim Short