Hi,
I found this post (http://es.infragistics.com/community/forums/t/17549.aspx) and attempted to implement it. I have a boolean value column that I want to show a conditional image for, but I cannot get it to work.
Dim hazardousImages As ValueList = e.Layout.ValueLists.Add("Hazardous")Dim vli As ValueListItem = hazardousImages.ValueListItems.Add(True, "Y")vli.Appearance.Image = My.Resources.hazmatvli = hazardousImages.ValueListItems.Add(False, "N")vli.Appearance.Image = Nothing
hazardousImages.DisplayStyle = ValueListDisplayStyle.Picturee.Layout.Bands(0).Columns("Hazardous").ValueList = hazardousImagese.Layout.Bands(0).Columns("Hazardous").CellActivation = Activation.NoEdit
' Create a ValueList with an image for each item. Dim teamImages As ValueList = e.Layout.ValueLists.Add("Team")vli = hazardousImages.ValueListItems.Add(True, "Y")vli.Appearance.Image = My.Resources.users2vli = teamImages.ValueListItems.Add(False, "N")vli.Appearance.Image = Nothing
hazardousImages.DisplayStyle = ValueListDisplayStyle.Picturee.Layout.Bands(0).Columns("Team").ValueList = teamImagese.Layout.Bands(0).Columns("Team").CellActivation = Activation.NoEdit
Private Sub AddBooleanIconToColumn(column As UltraGridColumn, trueIcon As Bitmap, falseIcon As Bitmap)
Dim trueCond As New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.Equals, True) Dim falseCond As New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.Equals, False)
Dim trueApp As New Infragistics.Win.Appearance() With { .Image = trueIcon, .ImageVAlign = Infragistics.Win.VAlign.Middle, .ImageHAlign = Infragistics.Win.HAlign.Left, .BackColor = Color.Blue } Dim falseApp As New Infragistics.Win.Appearance() With { .Image = falseIcon, .ImageVAlign = Infragistics.Win.VAlign.Middle, .ImageHAlign = Infragistics.Win.HAlign.Left } column.AllowRowFiltering = DefaultableBoolean.True column.ValueBasedAppearance = New Infragistics.Win.ConditionValueAppearance(New Infragistics.Win.ICondition() {trueCond, falseCond}, New Infragistics.Win.Appearance() {trueApp, falseApp})
End Sub
Thanks for your help!
Yes, this one is resolved. I have been able to produce what I need. Thank you!
ValueBasedAppearance is really designed for design-time. Setting it up at run-time is a lot of wasted effort, because it's much much easier and a whole lot less code to simple apply an appearance to the cell or row in the InitializeRow event.
Using the ValueList to translate a value into an image is useful in the case where you want just the image and no text, and/or if you want the user to be able to drop down the list and choose a new value.
It's not clear to me from your last post whether of not you've solved the problem and gotten what you needed. Do you still need help with this? If so, then it might help a lot if you could be more specific about exactly what you are trying to achieve.
Ok, to summarize:
Using ValueLists:
I am able to keep the FormattedText CellDisplayStyle and set the column CellDisplayStyle to FullEditorDisplay. I ended up with the following code:
Private Sub AddBooleanValueListToColumn(column As UltraGridColumn, trueIcon As Bitmap, falseIcon As Bitmap, layout As UltraGridLayout)
Dim teamImages As ValueList = layout.ValueLists.Add(column.Key) Dim vli As ValueListItem = teamImages.ValueListItems.Add(True, "Y") vli.Appearance.Image = trueIcon vli = teamImages.ValueListItems.Add(False, String.Empty) vli.Appearance.Image = falseIcon
teamImages.DisplayStyle = ValueListDisplayStyle.Picture column.CellAppearance.ImageHAlign = HAlign.Center column.CellAppearance.ImageVAlign = VAlign.Middle column.ValueList = teamImages column.CellActivation = Activation.NoEdit column.CellDisplayStyle = CellDisplayStyle.FullEditorDisplay
It looks like ValueBasedAppearance is to be used to modify the default display (text, checkbox for boolean, etc), correct?
I came up with this code, which doesn't work for showing the icon instead of default display value:
Private Sub AddIconToColumn(column As UltraGridColumn, trueIcon As Bitmap, falseIcon As Bitmap)
Dim trueApp As New Infragistics.Win.Appearance() With { .Image = trueIcon, .ImageVAlign = Infragistics.Win.VAlign.Middle, .ImageHAlign = Infragistics.Win.HAlign.Center } Dim falseApp As New Infragistics.Win.Appearance() With { .Image = falseIcon, .ImageVAlign = Infragistics.Win.VAlign.Middle, .ImageHAlign = Infragistics.Win.HAlign.Center } column.AllowRowFiltering = DefaultableBoolean.True column.ValueBasedAppearance = New Infragistics.Win.ConditionValueAppearance(New Infragistics.Win.ICondition() {trueCond, falseCond}, New Infragistics.Win.Appearance() {trueApp, falseApp})
Hi Robert,
I am just checking about the progress of this issue. Let me know if you need my further assistance on this issue.
Thank you for using Infragistics Components.
e.Layout.Override.CellDisplayStyle = CellDisplayStyle.FormattedText
This line of code is basically an optimization. It tells the columns not to use the editor to display the text in the cell, but to instead display it with a TextUIElement. This is good for performance, since it reduces the number of UIElements that the grid uses to paint.It's good for cases where you have a lot of changes occurring int he grid at high speed, and/or if you have a very large grid with a lot of cells on-screen at the same time.
The down side is that it disables any kind of editor-specific functionality in the cell, like showing images via a ValueList.
So removing this line of code probably won't have much of an effect on your application. But worst-case scenario, you could leave this line of code in place and and then override this setting on the one column with the ValueList:
e.Layout.Bands[0].Columns["My ValueList Column"].CellDisplayStyle = CellDisplayStyle.FullEditorDisplay;