Is there a possibility to change the visible value of a cell without changing the real value? Something like
if cell.value.equals("F") then
cell.displayValue = "Female"
end if
Thanks for any support.
Hi,
In a simple case like your example where you have a finite list of options (M or F) and you want to show more user-friendly test, then easiest way to do this would be to use a ValueList.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; ValueList vl = layout.ValueLists.Add("MF ValueList"); vl.ValueListItems.Add("M", "Male"); vl.ValueListItems.Add("F", "Female"); band.Columns["String 1"].ValueList = vl; band.Columns["String 1"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; }
You could also use UltraDropdown or a BindableValueList is your list data comes from a data source and you want to bind it.
The last line (setting the Style property) is optional, but I assume in a case of M/F you don't want the user to type in some other value.
Thank you for your answer. Because we provide a "Read-Only" grid, we don't want to have any "Drop-Down etc. controls" in our grid, but of course, this would be a solution.
Actually, we found our own way by implementing a "Draw-Filter", but this is a little bit complicated for such a simple "desire".
Anyway, it's some kind of disappointing, because other companies offer this addiotional "Display-Value" property. In my opinion, this would also be a very handy feature for the infragistics grid.
Thanks, Mike. That part to me isn't hard. The problem I'm having now is that the default draw methods are still being called so I end up with my custom draw string on top of the default. So an example would be helpful. I'm using v9.1, by the way, with app styling.
Oh, that's easy. I assume you are using the BeforeDrawForeground phase to draw the text. So just return true from DrawElement to tell the grid not to do the default drawing.
That's the issue. I do return true, but default painting happens anyway.
I also tried AfterDrawForeground and did a FillRectamgle there followed by a DrawString, but still got the double text. Returning true from DrawElemwnt did disable drawing, but I don't want to paint everything manually, just the text.
Phase was BeforeDrawForeground and element was the text editor. Which element should it be?
The correct element is EditorWithTextDisplayTextUIElement. Using that, it works.
That's why I was looking for an example. It must be a common use case. Anyway, I'll follow up with that utility and post back any success.
See... this is what I meant about using a DrawFilter being a very difficult and convoluted way to do this. :)
I'm not sure off the top of my head which element draws the text. What you can do is use the Infragistics UIElementViewer Utility to examine the element tree. I expect that it's some child element of the editor element that is actually drawing the text and not the editor element itself.