Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Trouble with ImageColumn

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Trouble with ImageColumn
Link Posted: 07-Sep-2005 04:14
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]
Link Posted: 07-Sep-2005 06:57
This problem is fixed and update will published at the nearest hours.
Now you can try to use GraphicsColumn, but to ocrrectly work with this column you should attach your ImageList to GraphicsColumn.ImageList property and use image indexes (not an images) in node values.


Dim values As System.Object() = New Object()
                                            {
                                            initId,
                                            ParentId,
                                            iImageIndex,  '<-----
                                            StripExt(_CT.Root.Name),
                                            _CT.Root.Nomenclature,
                                            _CT.Root.LifeCycle
                                            }
Link Posted: 07-Sep-2005 07:45
Thanks for the quick response... How do I obtain the new version, since I am currently using the trial version. I spoke to my boss, and he has authorized the purchase of FlyGrid, but we won't get the cash until Friday... I would like to continue with my development in the meantime.

Thanks again!
Link Posted: 07-Sep-2005 08:40
Downloat latest evaluation version, this problem is fixed in evaluation also.
Link Posted: 07-Sep-2005 09:54
The new version worked without modification of the code. Thanks so much for your prompt response and fix!  

I hope to obtain a licensed version of your component by Friday!
Link Posted: 07-Sep-2005 16:27
Thanks