ItemData

Started by Fred Tomke, March 15, 2009, 03:05:33 PM

Previous topic - Next topic

Fred Tomke

Hello,

I'm using the possibility of optional ItemData in comboboxes, listboxes, listviews and grids for assigning the item to a recordset in a database using the unique key. This is very interesting if the control has to show sorted items which are unsorted in the list in the AutoLISP program. Using the unique key the item can be identified very quick. For this idea I created a sample to use ItemData but I got some interesting detail I don't know whether tey're bugs or not. I attached the sample.

My questions are:
ComboBox, Sorted=True:

  • If I use dcl_control_setitemdata to assign a list of long it dows work but the numbers are assigned in a wrong order. Because of the property Sorted = True the items are sorted automatically and the order of list of integers does correspond to the new order of the combobox' list. Waht is the best way to assign the ItemDat?
  • To avoid the sorting problem I can assign the values line by line and the AddString method returns the rownumber of the newly added string. I thought I can use the SetItemData method to attach the ItemData. This way works very fine for the ListView. But when I click on such an item every item - except the last - return 0 as ItemData value. What did I wrong?

ImageComboBox, Sorted=True:

  • Attaching the data works very fine. But the list os not sorted although the property Sorted was set. Did I miss something?

ListBox, Sorted=True:

  • If I use dcl_control_setitemdata to assign a list of long it dows work but the numbers are assigned in a wrong order. Because of the property Sorted = True the items are sorted automatically and the order of list of integers does correspond to the new order of the listbox' list.
  • To avoid the sorting problem I can assign the values line by line and the AddString method returns the rownumber of the newly added string. I thought I can use the SetItemData method to attach the ItemData. This way works very fine for the ListView. But when I click on such an item every item except the last return 0 as ItemData value.


GridBox, Sorted=True:

  • Some items does not show a icon although the method uses a hardcoded icon image?

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

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

owenwengerd

These are definitely bugs. I'll need to think about a better strategy for dealing with this problem. My current design is obviously flawed.

While looking at Control\ComboBox.htm I noticed that it lists some incorrect methods. GetItem and SetItem should not be listed, and AddColor, AddList, AddPath, GetDir, and InsertString should be added. I will do that now and upload the revised file so you can see what I changed.
Owen Wengerd (Outside The Box) / ManuSoft

owenwengerd

It turns out that sorted image combo boxes are not possible (at least not with the built-in Windows control). Therefore, I have removed the Sorted property from Image Combo Box (note that I already changed the DEU help files).

The List Box and Combo Box should now be working correctly when setting and querying item data, including setting both at design-time. This should now work even when the list is sorted. The only exception is for combo box styles that automatically populate themselves; those styles of combo boxes ignore the List and ItemData properties.

I fixed the Grid bug that caused your cell images to get confused when the grid is sorted.

To fix the problem with the list box and combo box controls, I had to change the way the List and Item Data properties are managed internally. One nice benefit of the change is that those properties now get automatically updated whenever there is any change in the list, even changes that are not caused by your code. Although I didn't test it, this should also mean that (dcl_Control_GetList) after a (dcl_ListBox_Dir) will return the new list of files.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

Thank you very much, Owen.
Could this be an interesting sample for OpenDCL sample which demonstrates how to work with ItemData? I would improve it a bit and publish then?

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

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