I require the need to add a column to the UltraGrid that can display an image in it's cells.
The UltraGrid is bound to a data table however the column I need to add is not part of the dataTable. The column would be entirely fabricated on the front end.
Also I would need to create this column and add it after the InitializeLayout event has been triggered and I'm not sure how to access the columns in code at this point.
Any help would be greatly appreciated thank you!
Hi,
You can add an unbound column to the grid using the Add method on the Columns collection.
Why does it have to be added after InitializeLayout? In most cases, I would recommend adding the column inside the InitializeLayout event. But it's pretty much the same either way:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridColumn imageColumn = band.Columns.Add("My Image Column"); imageColumn.DataType = typeof(Image); imageColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Image; }
Outside of InitializeLayout, you would just use grid.DisplayLayout instead of e.Layout.
And then you would probably want to use the InitializeRow event to populate the image column with a value.
[code]
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Cells.Exists("My Image Column")) { e.Row.Cells["My Image Column"].Value = someImage; } }
[/code
Hai I Have a doubt,
How to get a image from folder to ultragrid cell
this is my code,
Dim val As Int32 For Each row As UltraGridRow In UltraGrid2.Rows
val = row.Cells(1).Value Dim foldername As String = "D:\SOFTWARES\Development\DART_PRODUCTS\TimeTracker2-DELTA\photo-Delta\" Dim filename As String = System.IO.Path.Combine(foldername, val & ".jpg") ' Dim file = Image.FromFile(e.Row.Cells(filename).Text) If System.IO.File.Exists(filename) Then e.Row.Cells("Image").Value = Image.FromFile(filename) End If Next
The above code are under Initializerow..
Please Help me
Did you set the DataType and also the Style on the Column like in the code I posted above?
Sorry for late rly.. I correct that thank you so much.