OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: Jim Short on March 08, 2009, 02:43:15 PM

Title: List Box OnInitialize select item in list
Post by: Jim Short on March 08, 2009, 02:43:15 PM
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)
)
Title: Re: List Box OnInitialize select item in list
Post by: Fred Tomke on March 08, 2009, 03:18:10 PM
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
Title: Re: List Box OnInitialize select item in list
Post by: owenwengerd on March 08, 2009, 03:38:06 PM
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.
Title: Re: List Box OnInitialize select item in list
Post by: owenwengerd on March 08, 2009, 03:49:59 PM
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.
Title: Re: List Box OnInitialize select item in list
Post by: Fred Tomke on March 08, 2009, 03:57:42 PM
Ok, I think, this is a good idea.
Fred
Title: Re: List Box OnInitialize select item in list
Post by: Jim Short on March 08, 2009, 04:59:42 PM
You guys are, "On it Boss"

Thanks,
Jim