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.
You could still use a ValueList in a read-only field. The user would not be able to drop down the list, or even see the dropdown arrow, but the translation would still occur and display the text.
Jonas Walti said: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.
We do offer this. The ValueList allows you to define the display text given a particular value.
Ok you're right, this works great... Thank you.
But if mit "conditions" for the display value of a cell refer to other cells of the row, I have to evaluate the condtion and set the "display value" in a draw filter?
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.
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.