Home - Forums-.NET - FlyGrid.Net (Windows Forms) - URGENT: Code that runs on Eval breaks under Pro 1.2.3.4

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

URGENT: Code that runs on Eval breaks under Pro 1.2.3.4
Link Posted: 04-Oct-2005 07:40
I wrote an app that uses FlyGrid.Net using the evaluation version that resulted from fixes discussed in the thread below:

http://www.9rays.net/support/viewtopic.php?t=106

I have finally obtained the full Pro version, but after installation I am now getting the exception listed below:

Exception
"Find finds a row based on a Sort order, and no Sort order is specified."

StackTrace
"   at System.Data.Index.FindRecords(Object[] key)
   at System.Data.DataView.FindRows(Object[] key)
   at System.Data.DataView.FindRows(Object key)
   at Middle_Tier.SelfRelatedForm.GetRows(Int32 parentId)
   at Middle_Tier.SelfRelatedForm.grid_VirtualMode_GetCount(NodeBase sender)
   at NineRays.Windows.Forms.FlyGrid.OnVirtualMode_GetCount(NodeBase sender)
   at NineRays.Windows.Forms.Data.VirtualRootNode.OnGetCount(NodeBase node)
   at 0.o.get_Count()
   at NineRays.Windows.Forms.Data.Rows.7x()
   at NineRays.Windows.Forms.FlyGrid.bk(Boolean )
   at NineRays.Windows.Forms.FlyGrid.bk()
   at NineRays.Windows.Forms.Data.Rows.ResetNodes()
   at NineRays.Windows.Forms.Data.Rows.8c()
   at NineRays.Windows.Forms.Data.Rows.8b()
   at NineRays.Windows.Forms.FlyGrid.OnNodeChange(Object sender, NodeBase node)
   at NineRays.Windows.Forms.Data.Rows.7H(Object , NodeBase )
   at NineRays.Windows.Forms.Data.RootNode.6V(NodeBase )
   at NineRays.Windows.Forms.Data.RootNode.ItemsChanged(Object sender, EventArgs e)
   at NineRays.Collections.ExtendedCollection.OnChanged(Object sender, EventArgs e)
   at NineRays.Collections.ExtendedCollection.OnChanged()
   at NineRays.Collections.NodeCollection.OnResume()
   at NineRays.Collections.ExtendedCollection.ResumeEvents()
   at NineRays.Windows.Forms.FlyGrid.Bx(FlyGridViewPort , Boolean )
   at NineRays.Windows.Forms.FlyGrid.EndInit()
   at NineRays.Windows.Forms.Data.Rows.set_VirtualMode(Boolean value)
   at Middle_Tier.SelfRelatedForm.PrepareGrid(FlyGrid grid)
   at Middle_Tier.SelfRelatedForm.LoadDataAndGrid()
   at Middle_Tier.SelfRelatedForm.reloadBtn_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   at System.Windows.Forms.Control.Show()
   at Middle_Tier.frmMain.OpenAssemblyTree()
   at Middle_Tier.frmMain.frmMain_Load(Object sender, EventArgs e)"

I have not made any changes to this code since the day I got it working (Sept 7th - the day you made fixes to the Evaluation version).

Could you please advise if there were any changes to the grid functionality that will require changes to my code, or if there is a bug that you need to fix?

Thanks!

Eric Popoff
Link Posted: 07-Oct-2005 07:04
I have now contacted you via phone, personal email, and this forum in regards to this issue... As yet I have not received a reply as to the status of your progress in troubleshooting this bug.

This morning I was dismayed to see that issues posted 3 days after my initial post have been answered. Could you please at least give me a status report on this issue? I have returned my references to the eval version, so I could continue development - my app works fine on the eval version. However, since I have made the purchase of the Pro Version it would be nice to deploy it...

Thank you in advance for your prompt response.

Eric Popoff
Link Posted: 10-Oct-2005 14:58
Sorry for delays with answer  
This exception describes problem - you should define primary key on your datatable - see the SelfRelated Sample (PrepareDataSet method).
PrimaryKey is a field associated with unique identifier of record.
Link Posted: 11-Oct-2005 09:03
Problem in  Middle_Tier.SelfRelatedForm.grid_VirtualMode_GetCount(NodeBase sender)
Could you provide me with code of this method?
Link Posted: 11-Oct-2005 09:47
Here is all the code involving Virtual Mode... The only changes made have been to assign a global variable (iRowIndex in GetNodeRow function) that I use elsewhere in the form. The rest of the code is verbatim from the SelfRelatedForm example.


    Private Function grid_VirtualMode_GetCount(ByVal sender As NodeBase) As Integer
        Dim aNode As NodeBase = sender
        If aNode.Depth = -1 Then 'root node
            'find rows with Parent == 0//root rows
            Dim rows As DataRowView() = GetRows(0)
            Return rows.Length
        Else
            Dim id As Integer = GetNodeId(sender)
            Dim childRows As DataRowView() = GetRows(id)
            Return childRows.Length
        End If
    End Function

    Private Function HasChildRows(ByVal parentId As Integer) As Boolean
        Dim obj As Object = CType(selfRelatedDt.DefaultView.Find(CType(parentId, Integer)), Integer)
        Return Not (obj = Nothing)
    End Function

    Private Function GetRows(ByVal parentId As Integer) As System.Data.DataRowView()
        Return selfRelatedDt.DefaultView.FindRows(CType(parentId, Integer))
    End Function

    Private Function GetNodeId(ByVal node As NodeBase) As Integer
        Dim row As DataRowView = GetNodeRow(node)
        If row Is Nothing Then
            Return -1
        Else
            Return CType(row("Id"), Integer)
        End If
    End Function

    Private Function GetNodeRow(ByVal node As NodeBase) As DataRowView
        Dim parent As NodeBase = node.Parent
        If (TypeOf parent Is VirtualRootNode) Then
            Dim rows As System.Data.DataRowView() = GetRows(0)
            If rows.Length > 0 Then
                'Capture node.index to allow for Datatable updates - EAP 10/6/2005
                iRowIndex = node.Index
                Return rows(node.Index)
            End If
        Else
            Dim parentNodeRow As DataRowView = GetNodeRow(parent)
            If (Not parentNodeRow Is Nothing) Then
                Dim parentId As Integer = CType(parentNodeRow("Id"), Integer)
                Dim rows As System.Data.DataRowView() = GetRows(parentId)
                If (rows.Length > 0) Then
                    'Capture node.index to allow for Datatable updates - EAP 10/6/2005
                    iRowIndex = node.Index
                    Return rows(node.Index)
                End If
            End If
        End If
        Return Nothing
    End Function

    Private Function grid_VirtualMode_GetNodeCellValue(ByVal sender As Object, ByVal node As NodeBase, ByVal index As Integer) As Object
        Dim parent As NodeBase = node.Parent
        Dim dataRow As DataRowView = GetNodeRow(node)
        If Not dataRow Is Nothing Then
            Dim col As Column = selfRelatedGrid.Columns.VisibleColumns(index)
            Return dataRow(col.FieldName)
        End If
        Return String.Empty
    End Function

    Private Sub grid_VirtualMode_SetNodeCellValue(ByVal sender As Object, ByVal node As NodeBase, ByVal index As Integer, ByVal value As Object)
        Dim row As DataRowView = GetNodeRow(node)
        Dim col As Column = selfRelatedGrid.Columns.VisibleColumns(index)
        If (Not row Is Nothing) Then
            row.BeginEdit()
            row(col.FieldName) = value
            row.EndEdit()
            row.Row.AcceptChanges()
            node.Modified = False
        End If
    End Sub

    Private Function grid_VirtualMode_HasChildren(ByVal sender As Object, ByVal node As NodeBase) As Boolean
        Dim i As Integer = GetNodeId(node)
        If i  -1 Then
            Return HasChildRows(i)
        End If
        Return False
    End Function


As I have stated before, the code ran (and still does!) on the eval version 1.2.1.39292. It throws an error (at the point shown in the stack trace from my initial post) when I upgrade to Pro version 1.2.3.4.

Aside from the iRowIndex var assignment, my code has not changed since the day I deployed the eval version. If I comment out the var assignments, the Pro version still errors out. It stands to reason that something must have changed in the subsequent revs of FlyGrid leading to the release of 1.2.3.4... Have there been any changes to the demo code that I am basing my code on (I didn't see any, but maybe I didn't look close enough)?

Thanks again for looking into this issue!

Eric
Link Posted: 11-Oct-2005 10:00
Here is problem code:
Private Function GetRows(ByVal parentId As Integer) As System.Data.DataRowView()
  Return selfRelatedDt.DefaultView.FindRows(CType(parentId, Integer))

End Function


Try following:
Private Function GetRows(ByVal parentId As Integer) As System.Data.DataRowView()
  'Why convert Integer to Integer?
  'Return selfRelatedDt.DefaultView.FindRows(CType(parentId, Integer))
  Return selfRelatedDt.DefaultView.FindRows(CType(parentId, System.Int32))
End Function
Link Posted: 12-Oct-2005 09:29
I made the change described in the last post... The code ran fine in the eval version. When I uninstalled the eval version, rebooted, and installed the pro version I experienced the same error described in the initial post:

"Find finds a row based on a Sort order, and no Sort order is specified."

In an attempt to determine what the problem is, I have added "print" statements to all of the subs/functions in my SelfRelatedForm. I ran the code under Pro 1.2.3.4 and captured the execution trace leading to the error. I then reverted the system (including a reboot) to the eval version
1.2.1.39292, and ran the code again. The code executes successfully.  

I am forwarding the 2 trace files to you at develop @ 9rays.net in hopes that they will help you discern the problem.

Eagerly awaiting a fix!

Eric
Link Posted: 12-Oct-2005 10:13
Send us all code of this form to quickly solve this problem,
but it seems that problem in your code - in virtual mode youк code provides data for the FlyGrid and Stack Tace shows that problem in your Getrows functions - incrrectly used criteria for filtering or PrimaryKey is changed in some other places of your code.  
Please analyze properties of data source in GetRows procedure to find incorrecntess.
Link Posted: 12-Oct-2005 10:19
I sent the entire form's code to you once before at develop@9rays.net. I will send it again...
Link Posted: 12-Oct-2005 17:34
You forget to send .resx file associated with this form.