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.
A DrawFilter will work, but it's probably the hardest way to do what you want here. There are much easier ways.
What I would do is simply hide the bound column of data and add an unbound column to the grid for display purposes. You would typically do this in the InitializeLayout event of the grid. Then you would handle the InitializeRow event and populate the cell of the unbound column with whatever data you want based on any other cell(s) in the row.
Another option would be to use a CreationFilter to set the Text on the TextUIElement in the cell. This is much easier than drawing the text yourself.
Do you have an example of how to do this using a DrawFilter?
I have the same requirement and am already using DrawFilters to draw some custom graphics, so it seems the logical place to do it.
Hi Tom,
The other methods I listed would still be much easier. Having a DrawFilter isn't the hard part - the hard part is drawing the text in the correct position and resolving the correct appearance, font, etc.
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.
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.
Phase was BeforeDrawForeground and element was the text editor. Which element should it be?
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.