Hi again,
I am using an UltraComboEditor within my UltraWinGrid to display different sorts of drop-down-lists (text only, text with image or image only). For text only and text with image, positioning of the elements and displaying of the drop-down-list work fine so far.
(1)But when I want to display only images (no text, neither DisplayText nor DataValue), I would like the images to be displayed centered within the drop-down-list. I am using DropDownListAlignment.Center but without effect. I guess this is caused by the fact that the size of the actual item is limited to the size of the image (plus text) but does not span the whole width of the drop-down-list. How can I adapt to this?
(2)Furthermore, when I click a cell containing the ComboEditor and it goes into EditMode, the TextEditor is being displayed on top of my image. I would like to achieve that no TextEditor is being displayed in this case, so that the user can see the currently selected image.
(3)The whole grid has been styled. I would like to set the BackColor of the list item on which my mouse is currently over to be the same color than the BackColor of my currently selected row(s).
(4)Since the App has been designed for touch input, I would like to adapt the width of the DropDownButton.
I have been looking to adapt these features on my own, but tbh it's quite a waste of time when you don't know where to look at... I hope you can point me in the right direction :-)
Okay, here's some sample code that gets almost everything you want.I have also attached the project with a simple grid and one column.
I am using ValueLists here instead of UltraComboEditor controls, because it's both easier to code and more efficient.
The only thing I did not do here is make the dropdown button bigger. You would have to use a CreationFilter for this, so it's a bit more complicated. But the way I have this sample set up, the ValueList will drop down when you click anywhere in the cell and not just on the button. So you may not need to make the button bigger.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridColumn column = band.Columns[0]; // Don't let the user type into the cell, make them select from the list. column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; // Align the image in the cell to the center. column.CellAppearance.ImageHAlign = HAlign.Center; // Since the image is aligned to the center, always show the dropdown button. Otherwise, the dropdown // button will onl show when the mouse is over the cell and this causes the image to shift. column.ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always; // Create a ValueList. ValueList vl = layout.ValueLists.Add("MyValueList"); // Align the images on the ValueList to the center. vl.Appearance.ImageHAlign = HAlign.Center; // Add some items with images. ValueListItem vli = vl.ValueListItems.Add(1, "Red"); vli.Appearance.Image = this.GetBitmap(Color.Red); vli = vl.ValueListItems.Add(2, "Yellow"); vli.Appearance.Image = this.GetBitmap(Color.Yellow); vli = vl.ValueListItems.Add(3, "Green"); vli.Appearance.Image = this.GetBitmap(Color.Green); // Only display images (no text) on the ValueList. vl.DisplayStyle = ValueListDisplayStyle.Picture; // Attach the ValueList to the grid column. column.ValueList = vl; // Set the default height of the rows in the grid to the height of the images. // Otherwise, the images get scaled down. layout.Override.DefaultRowHeight = 32; }
Hi,
I will see if I can whip up some sample code to do what you want, but I just want to make sure I understand what that is. :)
You say that the grid column DataType is a string, but the DataValue of the items on the list are numeric?
That's almost certainly going to cause problems if the data types do not match up. Why are the data types different?
Indeed, sorry for the flood of information here, I'll try to clear it up...
What you wrote above is about right, except that the touch functionality is optional (both, mouse usage and touch screen usage should be possible). But that is the exact reason why I would like the DropDownButton as well as the list items to be bigger (fat fingers syndrome).
The DataType of the column is 'String'. The problem is that the grid is being filled from a DataTable automatically and only after the grid has been filled I do attach the UltraComboEditors and their regarding ValueListItems, which are read from an external XML file. So the column first gets filled with a string value, then the UltraComboEditor is put on top of it.
When I try to change the DataType at this point, it won't let me do it (ArgumentException, 'DataType can only be set for an unbound column').
The DataValue is numeric, representing an unique id for the image (which is also stored in the DB). The image itself is being allocated to the valueListItem.Appearance.Image property.
I do not know upfront which of the columns will be equipped with UltraComboEditors, neither do I know upfront if there will be only images or images with text or just text. That all comes from the external XML file... Sounds messy, and it is!
I'm having a little trouble following all of your requirements here. Just to make sure I have it right, what you want here is a dropdown in a column that shows only images and no text and when you select an item on the list, the image appears in the cell and is centered. And all of this is on a touch-screen, so you want the list items and the dropdown button to be large enough to click on with a finger.
Is that right?
What's the DataType of this column? Are you storing an image in the data, or is it a numeric field and you just want to map the numbers into pictures?
I did find an answer to (4), but it does not make me too happy, since I am also using ScrollBars in my App. I guess they would be affected as well?
http://community.infragistics.com/forums/t/25261.aspx
Is there any new development concerning this issue?