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
Hi,
Okay... in that case, this is really easy. All you have to do is apply the image to the cell with the DisplayMember and the image of the selected item will show up in the edit portion of the control automatically.
If you image is in a separate column in the dropdown, then what I would do is hide that column:
private void ultraCombo1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Bands[0].Columns["Image 1"].Hidden = true; }
And then use InitializeRow to show that image in the DisplayMember column:
private void ultraCombo1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { e.Row.Cells["String 1"].Appearance.Image = e.Row.Cells["Image 1"].Value; }
I must be getting closer, but still no dice.
I see the image in the column if i dont hide it
I added the code as you told me to.. I get no error message, but only the code is shown.
Do I have to cast the Value to something else . my datasource returns it as a {System.Array}
I tried to replace the image i am adding in the initializerow... using a ressource from my project. when i do that and i drop down the ultracombo object, i see the image and the code in the same column.
However, I only see the code in the DisplayMember.
Here is my code
In the Sub New()
Dim bs As New BindingSource bs.DataSource = ListCouleurs BindingNavigator1.BindingSource = bs Me.UltraCombo1.ValueMember = CouleursColumn.Id.ToString Me.UltraCombo1.DisplayMember = CouleursColumn.Code.ToString Me.UltraCombo1.DataSource = bs
In the InitializeLayout
e.Layout.Bands(0).Columns(CouleursColumn.Image.ToString).Hidden = True
In the InitializeRow
e.Row.Cells(CouleursColumn.Code.ToString).Appearance.Image = e.Row.Cells(CouleursColumn.Image.ToString).Value