So we have this UltraGrid in which four of the columns are embedded editors, namely an UltraCheckEditor configured to act as a radio button. In each row, the user selects one of the four radio buttons, which are bound to four boolean properties of an object. I am not at liberty to change this design unless there's no other possible option.
This works fine as long as all four options are available. But we now have to add some rows in which only two of the four radios are allowed options, and we can't get this to work. There seems to be no way to either make a radio in one cell disabled, or make it not visible, or cause the cell to not display any editor control. Can someone point me to some technique that allows any one of these three options? So far, no matter what I do, there is always either a checkbox or a radio button displayed, it's always visible, and it's always enabled. I even tried changing the business object to return null instead of true or false on the unwanted columns, and still got a checkbox (which showed as checked!).
The nearest I've gotten to a blank column so far was to change the cell's Style to ColumnStyle.FormattedText. On one trial, this produced blank columns, but on the next run, it displayed the word "False". Is there a way to force one of these to display blank text?
The nearest I've gotten to a disabled column was to set the Style to ColumnStyle.Color, which produced a little white rectangle that didn't do anything when clicked.
Why can't I just tell it to use a regular radio button in a disabled state??
Thanks -- ColumnStyle.Image and Activation.Disabled both worked. (Activation.NoEdit did not.) I'm going to go with the image style instead of disabling, because with the radio imagery we've got, the disabled state was not visually distinct enough. And hiding the whole cell looked funny.
Here's a quick sample I threw together. In the sample there are 5 columns. The first column is an integer which indicates how many enabled Checkboxes the row should have. The next 4 columns are the checkboxes.
Run the sample and change the value in Column 0 and the checkboxes will enable or disabled themselves appropriately (after you leave the cell).
Hi Paul,
What you can do is handle InitializeRow event. This event will pass you the row. Presumably, you will examine the row contents and then make a determination on which CheckBoxes should be visible.
For the ones that should not be visible, you can set the Hidden property on the cell.
e.Row.Cells["CheckBox 3"].Hidden = true;
This will hide the entire cell. If that's not what you want, and you still want the cell to display, but display empty, then you could set the Style on the cell to Image. Since the cell's value cannot be translated into an image, it will appear blank.
Another option would be to set the Activation property on the cell to Disabled.
Just remember that InitializeRow fires initially when the row is created and also any time a value in that row changes. So whatever approach you decide to use here, it might be a good idea to set the property on all of the cells (to both enable and disable the appropriate cells).