I have a case where I have a datasource with an ID, a Code and an Image.
I have no problems data binding a tlist of that entity to a grid or an ultracombo to display it.
For this particular requirement, I want to have my usercontrol which uses a picture box and a ultralabel to show as the displaytext of the ultracombo.
So no only with I see the code and the image when i drop down (which I can do now) but whatever I choose, I will be able to see it in the display value area (the not dropped down combo)
Is that something that is doable ?
Thanks in advance
Got my hands on a 9.2.20092.2058 version and sure enough it worked..
thanks for your help
Fred
Me.UltraCombo1.DisplayMember = CouleursColumn.Code.ToString
Most Columns are hidden
For Each c As UltraGridColumn In e.Layout.Bands(0).Columns c.Hidden = True Next e.Layout.Bands(0).Columns(CouleursColumn.Image.ToString).Style = ColumnStyle.Image e.Layout.Bands(0).Columns(CouleursColumn.Code.ToString).Hidden = False
Using version 8.2.20082.1000
Would like to get my boss to pay for an upgrade soon.. but for now no go
Yeah I use UltraCombo1.InitializeRow
Hm.
The Code column is your DisplayMember column, right? Do you have any hidden columns here?
What version of the controls are you using? Maybe this is a bug in an old version.
What event are you using to apply the Image? IniitalizeRow?
OK I ported your code to VB.NET and now I get an image for the datarow which have an image
however even with the bitmap,
If Image Is Nothing Then e.Row.Cells(CouleursColumn.Code.ToString).Appearance.Image = My.Resources.Notepad_48 Else e.Row.Cells(CouleursColumn.Code.ToString).Appearance.Image = Image End If
both those possibilities do not change
This is what i get now....
Fred Morin said:Do I have to cast the Value to something else . my datasource returns it as a {System.Array}
You mean your image column is an array? Okay, so your images are stored in a Byte array. That makes this a little trickier. I assume, in that case, that you also don't see the image in the DisplayMember column of the dropdown, either.
In that case, you have to convert that byte array into a System.Drawing.Image before you assign it to the Appearance. The grid does this for you in the column containing the byte array, but the Value of the cell will still return the Byte array data and not the image.
There's no really easy way to do this, and I don't have a sample with byte array data to test with, but I think what you can do is something like this:
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { object imageCellValue = e.Row.Cells["Image column"].Value; Image image = GetImageRendererImage(e.Row, e.Row.Band.Columns["Image column"], imageCellValue); e.Row.Cells["DisplayMember Column"].Appearance.Image = image; } internal static System.Drawing.Image GetImageRendererImage(UltraGridRow gridRow, UltraGridColumn gridColumn, object cellValue) { EmbeddableImageRenderer embeddableImageRenderer = gridRow.GetEditorResolved(gridColumn) as EmbeddableImageRenderer; if (embeddableImageRenderer == null) { Debug.Fail("GetImageRendererImage is only valid for cells that are using an EmbeddableImageRenderer"); return null; } EmbeddableEditorOwnerBase editorOwner; object ownerContext; GetOwnerInfo(gridRow, gridColumn, out editorOwner, out ownerContext); Stream imageStream; bool disposeImage; return embeddableImageRenderer.GetImage(cellValue, editorOwner, ownerContext, out imageStream, out disposeImage); } internal static void GetOwnerInfo(UltraGridRow gridRow, UltraGridColumn gridColumn, out EmbeddableEditorOwnerBase editorOwner, out object ownerContext) { IGridDesignInfo iGridDesignInfo = gridRow.Band.Layout.Grid as IGridDesignInfo; editorOwner = iGridDesignInfo.GetEditorOwner(gridRow, gridColumn); ownerContext = gridRow; }