Hi,
I am using infragistics 9.2 and I want to put multiple images and texts in one cell like this :
How can I do this, perhaps using CreationFilter ??
Regards.
A CreationFilter would be one way to do this.
Another option would be to use formatted text. The UltraFormattedTextEditor control can do what you have shown here by embedding images in the text. If you want to try it and see what it looks like, put an UltraFormattedTextEditor on the form and go to the Value property. Clicking the ellipsis will take you to the formatted text editor where you can edit text just like a word processor. You can set up your text with the embedded images and then look at the Xml that was generated. That will give you an idea of how to build the strings you will need for the Value of your grid cells.
To get the grid to recognize the Xml, you just set the column.EditorComponent to an instance of the UltraFormattedTextEditor.
In fact, you don't even need the FormattedTextEditor, control, you can just set the Style of the column to FormattedText. Here's some sample code I threw together. I have a grid bound to an UltraDataSource with a single column and I am populate the value of that single column with Xml strings that contain embedded image data, which I generated from the images in an ImageList component.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridColumn column0 = band.Columns[0]; column0.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText; } private void Form1_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string imageString = GetImageTag(this.imageList1.Images[0]); sb.Append(imageString); sb.Append("Title1"); imageString = GetImageTag(this.imageList1.Images[1]); sb.Append(imageString); sb.Append("Title2"); imageString = GetImageTag(this.imageList1.Images[2]); sb.Append(imageString); sb.Append("Title3"); this.ultraDataSource1.Rows.Add(new object[] {sb.ToString()}); } private static string GetImageTag(Image image) { return string.Format("<img style=\"width:{0}px; height:{1}px;\" data=\"{2}\"/>", image.Width, image.Height, Infragistics.Win.FormattedLinkLabel.FormattedLinkEditor.EncodeImage(image)); }
Never mind I figured this out. I was confused about the escape characters. I copied the code which used C# and changed it to VB and kept the \ escape characters in. Once I took these out this worked fine
So I tried using this code in my project but my formattedtext column is an unbound column. I was using the code below to add the image into it in the InitializeRow event. I fist set the cell value to the string but that did not work and just showed all the text unformatted in the cell. Then I looked at your example and tried to use the string to create an object and then set the value ot that object but I get an error saying it must implement IConvertible. What am I doing wrong?
Private Sub grdResults_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles grdResults.InitializeRow
Dim strTypeDisplay As String
strTypeDisplay = ""
If e.Row.Cells("ResultType").Value = CentralSearchResultType.Customer Then strTypeDisplay = strTypeDisplay + GetImageTag(CsiImageResources.CsiImageList.Images(38)) + " " ElseIf e.Row.Cells("ResultType").Value = CentralSearchResultType.Vendor Then strTypeDisplay = strTypeDisplay + GetImageTag(CsiImageResources.CsiImageList.Images(39)) + " " Else strTypeDisplay = strTypeDisplay + GetImageTag(CsiImageResources.CsiImageList.Images(40)) + " " End If
If e.Row.Cells("Status").Value = "A" Then strTypeDisplay = strTypeDisplay + GetImageTag(CsiImageResources.CsiImageList.Images(41)) '+ ""
Else strTypeDisplay = strTypeDisplay + GetImageTag(CsiImageResources.CsiImageList.Images(42)) '+ ""End If
Dim x As Object = New Object() {strTypeDisplay}
e.Row.Cells("DisplayMatchNumber").Value = x
End Sub
Private Function GetImageTag(image As Image) As String
Return String.Format("", image.Width, image.Height, Infragistics.Win.FormattedLinkLabel.FormattedLinkEditor.EncodeImage(image))
End Function
In case this helps this is the contents of strTypeDisplay
"<img style=\"width:16px; height:16px;\" data=\"AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAggEAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAARdJREFUOE+VkjGyQDAYhN1JpVPpHMAFVEavU6mMXqVTUalULmAUOneQRqfy5ovE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