Hi there,
I have an UC that displays two columns from a query.
Question is, how can I have it to use both columns as the selected value?
I mean, to display once selected from the dropdown list, ie Name and Age, separated by a space ?
Thanks in advance!
Hi,
The UltraCombo determines which field on the list to use for it's data and display values by looking at the DataMember and DisplayMember properties, respectively. You can only specify one column for each of these.
So if you want the display or value to be the combination of two columns, then you need to create an additional column on the list that contains the combined value. This is pretty easy to do. What you would do is handle the InitializeLayout event of the UltraCombo and add an unbound column. Then you use the InitializeRow event to populate that column's Value with the combination of values from the other columns in the same row. Then you just set the ValueMember or DisplayMember to point to the unbound column.
I know it's been a long time since this was closed but I struggling with this now.
It only lets me choose from the columns in the bindingsource. I can't choose an unbound column for the DisplayMember.
Am I missing something?
Hi Mike,
What's the problem? Why can't you choose an unbound column? The UltraCombo really makes no distinction between the two. And setting the DisplayMember is just a string. So what's stopping you from choosing an unbound column?
I am spoiled in the designer by having all the possible values to choose from. The unbound columns do not show up, but I can type it in.
So is it a bug if all the choices do not show in the designer?
Hm. I just tried it out and it seems you are right. The Designer only displays Bound columns. I'm really not sure why that is. There's no reason why you should be able to use an Unbound column as your ValueMember or DisplayMember. Might be a bug in the designer.
You can, of course, just type in the name of the column you want, or set it at run-time.