Hello out there,
I have an ComboBox which is connected to a DataSet with small Images (and an hidden value column).
If I press the Button on the ComboBox, the images are show and I can select one.
But, when I do this, the Image is not shown in the Combobox, but it's type: System.Drawing....
How can I modifiy the ComboBox to show my Images?
Thanks,
Frank
Hi Frank,
I think you will need to use UltraComboEditor for this instead of UltraCombo.
Assuming you bind the UltraComboEditor to some data source, you would loop through the items in the list and assign an Appearance.Image to each one. Then you tell the list to display the images by setting:
this.ultraComboEditor1.Items[0].ValueList.DisplayStyle = ValueListDisplayStyle.Picture;
I set up an UltraComboEditor as described (except it's not bound -- I initialize a static list) and made it the EditorControl of a column in a tree. The tree has an image list, and the column data values are integer indices into it. The tree is initially displayed correctly.
The editor dropdown arrow is always visible (OK for now, though I'd like it to appear on hover as in the "grid with editors" sample).
When I open the dropdown list (only images are shown -- good), the image in the cell disappears. It should stay the same until I change it.
When I change it by clicking an item in the list, the list closes up but there is still no image in the cell. If I exit the application without any further action, there is an invalid index exception in Dispose(). If I instead click outside the tree, the old image appears and no exception occurs on app exit.
I subscribed to the editor's SelectionChanged, ValueChanged, and SelectionChangeCommitted events, but none of them are ever fired. (I verified that the lines of code doing the subscriptions do get executed).
Any ideas, either on how to get the editor to work, or on how to debug (i.e. why I'm not seeing events)?
By the way, are there any books on using Infragistics components?
When you populate the UltraComboEditor's ValueList items, what are the values you are using? It sounds to me like the values on the list aren't matching up to the values in the tree node column. Or, this might be a bug in the tree.
Or, it might be case of mismatched ImageLists. I'm not entirely sure where the images will come from when you use an ImageList like this - the tree or the UltraComboEditor. Perhaps you need to assign the same ImageList to both to make sure they are in synch.
bobgru said:I subscribed to the editor's SelectionChanged, ValueChanged, and SelectionChangeCommitted events, but none of them are ever fired. (I verified that the lines of code doing the subscriptions do get executed).
When you say editor here, I assume you mean Editor Control - The UltraComboEditor. The event of the control do not fire, because selecting an item in the tree has no effect on the control. The Tree doesn't use the control itself - the UltraComboEditor just provides a copy of it's internal editor for use by the tree.
The ValueList items are integers 0 and 1. The image list has two bitmaps in it. The tree and UltraComboEditor both get the same image list (I couldn't detect a change in behavior from before the editor's imagelist was assigned; the tree's imagelist seems to be critical). The editor's items each have an Appearance.Image property set to the item's index, and ValueList.DisplayStyle is Picture.
Other potentially relevant info: the editor's DropDownStyle is DropDownList (i.e. can only pick from list). The HeaderAppearance.Image of the unbound column is a bitmap object. The ColumnSet.AllowCellEdit property is Full.
I don't follow why the editor's events aren't fired. I created an instance of an UltraComboEditor and subscribed to events on that instance. Are you saying the tree uses a copy of that object that doesn't include its event subscriptions? Or, perhaps, the editor isn't firing its events because of the way in which it's being used (internal object that isn't responsible for firing events of the public class)?
In any case, it seems like a handicap that I can't manage what's happening to the editor.
Hi,
I can't see anything wrong with this code. This looks like a bug to me. When the cell is active, for some reason, it's just not showing the image.
I'm forwarding this thread over to Infragistics Developer Support so they can write this up for developer review.
Sure, see attached.
We seem to be going in circles here. :)
Perhaps it would be best if you created a small sample project demonstrating the behavior you are getting so I can see what's wrong.
I switched the datatype to integer and there was no difference in behavior! In any case...
Your comments have me thinking I don't need the unbound column. I should be able to get what I want by assigning the UltraComboEditor as the EditorControl of the original integer column and just display as images.
In fact I was able to do this, so it's a step forward. I am now able to change the value via the dropdown of images, but there are still two problems:
1) When a cell enters edit mode and the dropdown list is opened, the current cell value disappears.
2) When a list item is selected and the dropdown closes, the cell doesn't show its new image until it loses focus.
It seems the WinComboEditor is confused about how to display the current value when in edit mode. How can I tell it to take the current value and use it as an index into the imagelist? Remember that the value list already displays correctly, and after changing focus to another cell, the first cell repaints correctly.
bobgru said:The column on which the EditorControl is set has DataType = typeof(Bitmap).
Okay... that's why it doesn't work. If your ValueList has integers in it, then when you select an item on the ValueList, it will try to put an integer into the cell. An integer is not a Bitmap and cannot be converted to one.
If you want the column to be of type Bitmap, then your ValueList would have to contain Bitmap values. If you are mapping an integer value to an image, then you should make the column of type Integer.