I have put in a requisition for your great component - I should be buying it late this week!
I am trying to implement an image column in a FlyGrid using code I've modified from the SelfRelated form example. I am populating the heirarchical structure fine by parsing a my home-grown Component Tree. When I try to add the images from an imagelist, all I get is the default System.Drawing.Bitmap
Here is the code I am using to PrepareGrid:
Private Sub PrepareGrid(ByVal grid As FlyGrid)
grid.Columns.Items.Clear()
'Image Column
Dim imageCol As New ImageColumn("Image")
imageCol.FitMode = ColumnFitMode.Exact 'PartName Column
Dim PartNameCol As New HierachyColumn("PartName")
PartNameCol.HotTrack = False
PartNameCol.ShowLines = True
PartNameCol.FitMode = ColumnFitMode.Exact
PartNameCol.Width = 300
'Nomenclature Column
Dim NomenCol As New Column("Nomenclature")
NomenCol.Width = 75
NomenCol.FitMode = ColumnFitMode.Exact
'LifeCycle Column
Dim LifeCol As New Column("LifeCycle")
LifeCol.Visible = False
grid.Columns.Items.AddRange(New Column() {imageCol, PartNameCol, NomenCol, LifeCol}) grid.Rows.DataSource = selfRelatedDt
selfRelatedDt.DefaultView.Sort = "Parent ASC"
AddHandler grid.VirtualMode_GetCount, AddressOf Me.grid_VirtualMode_GetCount
AddHandler grid.VirtualMode_GetNodeCellValue, AddressOf Me.grid_VirtualMode_GetNodeCellValue
AddHandler grid.VirtualMode_SetNodeCellValue, AddressOf Me.grid_VirtualMode_SetNodeCellValue
AddHandler grid.VirtualMode_HasChildren, AddressOf Me.grid_VirtualMode_HasChildren
grid.Rows.VirtualMode = True
End Sub
Here is the code I use to add the image when I add the row to the grid:
Private Sub FillData(ByVal _CT As CompPDM.ComponentTree, ByVal dt As DataTable, ByVal ParentId As Integer)
Dim child As CompPDM.Component
'Add Assembly name to pnlTree header text
pnlTree.HeaderText = "Assembly Tree - " & _CT.Root.Name
'Determine image to display for Node
iImageIndex = GetImage(_CT.Root.Name.ToLower)
'Modify to handle writing Root Node then check for Children - EAP 9/2/2005
Dim initId As System.Object = 1
Dim values As System.Object() = New Object() {initId, ParentId, ImageList1.Images(iImageIndex), StripExt(_CT.Root.Name), _CT.Root.Nomenclature, _CT.Root.LifeCycle}
Dim dr As DataRow = dt.LoadDataRow(values, True)
If _CT.Root.Children.Count > 0 Then
For Each child In _CT.Root.Children
'Dim id As Integer = CType(dr("Id"), Integer)
CurrID = CurrID + 1
FillChildData(child, dt, ParentId) 'add children for this row
Next
End If
The GetImage() function returns the index of the proper image from the imagelist.
I use the same logic to recursively fill the images for the children nodes.
Not sure what I'm doing wrong, but any help would be greatly appreciated!
Thanks!
[/img]