I have an ultracomboeditor using a dataset datasource set as the editorcontrol on one of the columns in an ultragrid based on another datasource. I want the dropdown items of the comboeditor to have different forecolors based on another value in the item's datarow and another data value in the ultragrid row. Is there a way to do this?
For example:
The Ultragrid has an available rooms column. The user can select a room from a comboeditor tied to a "rooms" datatable. Each room has a maximum occupancy value. The ultragrid also has an expected occupancy column. When the user drops down the rooms list, I'd like it to display rooms whose maximum occupancy is less than the expected occupancy in a different color so the user can see that the room may not work. (I don't want to filter out rooms from the list, because the user could override.)
It sounds like the you're already going to have the dropdown loaded and the user will fill in the expected occupancy. if thats correct you will not be able to use the initialize row event so you'll need to write a sub to to the work.
Private sub ChangeRowColor(expectedocc as integer)
dim orow as ultragridrow
dim i as integer
for i =0 to mycombo.rows.count-1
if mycombo.rows(i).cells("Occupancy").value > expectedocc then
oRow.Appearance.BackColor = Color.CadetBlue
else
oRow.Appearance.BackColor = nothing 'this will reset the color to default
end if
next
if you load the combo after the the expected occupancy is set then use the initialize row event.
I'm not trying to change the grid colors. I'm trying to change the combo's dropdown item colors, so that when they are looking at the list of options on the dropdown, they can see that it might not be optimal.
Hi,
Loop through the Items collection in the UltraComboEditor and you can set an Appearance on each ValueListItem.
Looping through every item is not very efficient, though. You might be better off using an UltraDropDown control instead of UltraComboEditor. That way you could use the InitializeRow event of the UltraDropDown. But it really depends on how many items are on your list. If it's just a few, then UltraComboEditor should be fine.
Thought about using an ultradropdown, but want the view styling that the comboeditor provides.
As for looping through the valuelistitem... this editor IS on a grid and the it's list is databound. Is that an still option? How exactly would that work?
I see now... the "MORE" menu comes up with the options all in light grey, which made me think that they weren't enabled.
I'm looking at the valuelistitems now. I should be able to proceed off this one way or another. Thanks!
Hi Jeff,
There is an option to edit your posts. It's on the MORE button in the upper right corner of each post.
Anyway, the fact that the combo is bound and used in a grid doesn't matter. You simply use the combo's Items collection and loop through the items. It makes no difference if those items were created in code or through DataBinding.
Bleh, this forum needs an edit option on posts. I meant to say "this editor is on a grid and its list is databound." :-/