Let's say I have to display green button icon for column value "1", yellow for column value "2" and red for "3" . I have two requirements
1. Column shows both value and its associated icon. ie. Column value shows "1" <green button icon>, "2" <yellow button icon>, "3" <red button icon>
2. Columns shows only the icon representing the value
Questions:
a. From reading the forum, valuebasedappearance seems to help me achieve both requirements very easily. Is that correct?
b. How would I achieve sorting of the columns in requirement #1 and requirement #2 ?
It might be the ImageList corrupting the images. Make sure you set the size and color depth on the ImageList before you add any images to it. Otherwise, any images you add to the ImageList will be coerced into the default settings for the ImageList.
Thanks Mike, that helpded me get started and was a good example.
I don't know if I'm doing something wrong but the images I'm loading 32bit, 16x16 are all getting distorted in the grid and look terrible. I have uploaded a screen print including the images I have in windows explorer and the same images as they are displayed in the grid.
The grid images are showing blue as the shadow instead of a light grey, also they look stretched and jagged edges. I'm loading them from an imagelist set to 16x16 and 32bit.
Any ideas what is going wrong?
Here's some sample code. There's really not much to it.
{ UltraGridLayout layout = e.Layout; UltraGridBand rootBand = layout.Bands[0]; UltraGridOverride ov = layout.Override; // Create a ValueList ValueList vl = layout.ValueLists.Add(); // Set it's DisplayStyle to Pictures-only. vl.DisplayStyle = ValueListDisplayStyle.Picture; // Add some items and assign an image to each item. ValueListItem item = vl.ValueListItems.Add(1); item.Appearance.Image = DummyDataCreator.GetTextBitmap("1"); item = vl.ValueListItems.Add(2); item.Appearance.Image = DummyDataCreator.GetTextBitmap("2"); item = vl.ValueListItems.Add(3); item.Appearance.Image = DummyDataCreator.GetTextBitmap("3"); // Assign the ValueList to the column rootBand.Columns["Int32 1"].ValueList = vl; }
Hi Mike,
Can you point me towards an example where you put this together?
I want to do something similar, I want to display an image in the cell and no text and don't really understand how to use the valuelist to achieve it? The image would be different depending on the content, for instance if the value pulled back is 1 then display a red arrow image, 2 display a orange arrow etc...
Any pointers would be welcome.
Cheers,John
Okay, this really isn't the same thing you described earlier. Or at least it's not what I understood. What I would probably do in a case like this is simply hide the Status column and then use the InitializeRow event of the grid to set the Cell.Appearance.Image on the Number cell to display the appropriate image based on the Status (which is hidden).
In this case, the column would sort based on the Number, not the Status. But if you want to change the sorting behavior of that column, this is easily accomplished using the SortComparer property on the column.