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!
Hi Robert,
Thank you for contacting Infragistics Developer Support.
The code you have posted with the ValueList should work, except that you are adding the True ValueListItem twice to the Hazardous ValueList and you don’t add it to the Team ValueList. Other than that it seems fine. If that doesn’t fix the issue, make sure that you haven’t explicitly set the Style of the column to something like CheckBox. Also make sure that the images are properly loaded and that no exception is thrown.
I have attached my sample which uses your code and works fine. Please modify it so it reproduces your issue and I will be glad to continue investigating your issue.
I am looking forward to your reply.
Thanks! I took this example and compared it to mine and found no differences. Since this is an old application that we just keep adding enhancements to, I went through our code and commented out any place we were modifying the grid. This allowed the images to show, so I restored these lines one by one until I found the culprit.
Private Sub dgrServices_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles dgrServices.InitializeLayout
e.Layout.Override.AllowRowFiltering = DefaultableBoolean.Falsee.Layout.Override.RowSelectors = DefaultableBoolean.Falsee.Layout.Override.AllowColSizing = AllowColSizing.Freee.Layout.Override.HeaderClickAction = HeaderClickAction.SortMultie.Layout.Override.CellClickAction = CellClickAction.RowSelecte.Layout.Override.CellDisplayStyle = CellDisplayStyle.FormattedTexte.Layout.ViewStyle = ViewStyle.SingleBande.Layout.Override.BorderStyleCell = UIElementBorderStyle.Nonee.Layout.Override.BorderStyleRow = UIElementBorderStyle.Dottede.Layout.Override.HeaderAppearance.TextHAlign = HAlign.Centere.Layout.ScrollBounds = ScrollBounds.ScrollToFille.Layout.TabNavigation = TabNavigation.NextControlOnLastCell
If e.Layout.IsDisplayLayout ThenWith e.Layout.Bands(0)
AddBooleanValueListToColumn(e.Layout.Bands(0).Columns("Requested"), My.Resources.requested, Nothing, e.Layout)AddBooleanValueListToColumn(e.Layout.Bands(0).Columns("Hazardous"), My.Resources.hazmat, Nothing, e.Layout)AddBooleanValueListToColumn(e.Layout.Bands(0).Columns("Team"), My.Resources.users2, Nothing, e.Layout)
End WithEnd If
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 = trueIconvli = teamImages.ValueListItems.Add(False, String.Empty)vli.Appearance.Image = falseIcon
teamImages.DisplayStyle = ValueListDisplayStyle.Picturecolumn.CellAppearance.ImageHAlign = HAlign.Centercolumn.CellAppearance.ImageVAlign = VAlign.Middlecolumn.ValueList = teamImagescolumn.CellActivation = Activation.NoEdit
The bold line above caused the images to now show, even though this line was run before setting the ValueList on the column. I commented it out and don't think we will need to use it in the future. It surprised me that this override was applied on top of setting this same property on the column, thus hiding the icons.
I also was able to show the icons using ValueBasedAppearance, but I don't know how to hide the checkbox that is shown being a Boolean value column. Any suggestions on that, in case we need to use it in the future. Is this a possible use for the ValueBasedAppearance?
Thanks!
Thank you for the reply.
What you could do in order to display only images in your columns is to set their style to Image. You could use:
column.Style = ColumnStyle.Image
I have modified my sample in order to demonstrate this approach.
Please let me know if you have any additional questions.
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;