two diagonal red lines across the grid

Posted by: parez81-fp on 8 September 2017, 1:16 pm EST

  • Posted 8 September 2017, 1:16 pm EST


    Sometime I get two diagonal red lines across the grid and it makes it unusable.It doesnt happen often.But when it does i have to close the form and open again.And if i run the same request again(same input for the grid) it works next time.
    It is accompanied by index out of bound error. Is this is a known problem?
    I will attach a screenshot next time that happens and more details.
    This probably could be something on my end but i just wanted to make sure that its not a bug.
  • Replied 8 September 2017, 1:16 pm EST

    I mananged to get stacktrace

       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

  • Replied 8 September 2017, 1:16 pm EST

    Hi,

    This error is accompanied by  "Invalid row index: 0 ( must be -1 and -1)" error.
    I dont know where the error  occurs. I have set up a conditional break point so that i debug it.

    my version number is 4.0.2001.2005.  winforms 3.0  c# on VS2008.

    There is no definite way of replicating the error.The application makes a TCP/IP requests and sends xml messages to the server which is behind firewall. I mite not  be able to give you access to the app.

  • Replied 8 September 2017, 1:16 pm EST

    Have you tried getting version 4.0.2003 to see if that solves the problem?  I have never seen this issue in any release of version 4.
  • Replied 8 September 2017, 1:16 pm EST

    Hello,


    This would happen any time there is an exception in the paint code. This is possible to be a bug, but as Bob stated, we have fixed any bugs we are aware of. Make sure you are using the latest release. If you are, could you post a small zipped project reproducing the issue for us to debug?

  • Replied 8 September 2017, 1:16 pm EST

    I used to see this occassionally when something was not getting serialized correctly or the references were mixed up but I haven't seen it in years.  What version are you using?
  • Replied 8 September 2017, 1:16 pm EST

    Hello,

     I'm curious what is acceptable to access/modify outside of the main thread and what is not?
     

  • Replied 8 September 2017, 1:16 pm EST

    Hello,


    Really nothing is acceptable to access/modify in a seperate thread unless you invoke the call through a delegate.

  • Replied 8 September 2017, 1:16 pm EST

    Thanks for letting us know.
  • Replied 8 September 2017, 1:16 pm EST

    Its been good so far.. its not crashed after i made the changes.I will get back to you guys if it happens again..
  • Replied 8 September 2017, 1:16 pm EST

    Hello,


    In addition to what Bob stated, are you making calls on a seperate thread to change information on the Spread like RowCount etc.?

  • Replied 8 September 2017, 1:16 pm EST

    Yea.. I am using a separate thread to popuate the grid.
    you think that could be the problem? I started seeing more of this problem after i implemented the async populatation of the grid but i cannot say for sure i had not seen it before.


    I just now changed the code to

    fpSpread1.Invoke((MethodInvoker)delegate() { fpSpread1.ActiveSheet.Models.Data = new FarPoint.Win.Spread.Model.DefaultSheetDataModel(value, typeof(FinancialDataSummaryItem)); });
    that will make the ui thread to populate the grid.

    I will keep you posted.


  • Replied 8 September 2017, 1:16 pm EST

    Hello,


    I believe this is the cause of the issue. Running the seperate thread on a delegate call should fix the issue. If it does not, could you post a small zipped project reproducing this issue for us to debug?

  • Replied 8 September 2017, 1:16 pm EST

    Hello,

    I was not able to debug the issue reported by you, from the code provided by you. I would need the complete sample to debug your issue and help you out further. I would also suggest you to update to the latest version of Spread v4.0.2026, try executing your application with the latest version,  and check out if it resolves your issue. Please let me know your observations. You can find the latest version of Spread v4.0.2026 at the following link:

                                                                           ftp://ftp.fpoint.com/SpreadWinForms4/

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 1:16 pm EST

    The Exception I am getting..


    ************** Exception Text **************
    System.Exception: Exception handled in FpSpread.WndProc ---> System.Exception: Exception handled in FpSpread.OnPaint() ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at FarPoint.Win.Spread.SpreadView.e(Graphics A_0)
       at FarPoint.Win.Spread.SpreadView.g(Graphics A_0)
       at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
       --- End of inner exception stack trace ---
       at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
       at System.Windows.Forms.Control.WmPaint(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       --- End of inner exception stack trace ---
       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3623 (GDR.050727-3600)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll


     I will Explain where the datatable gets updated which is bound to datasource of farpoint spread.


     


    ************************************************************************************************************************************************************** 
            private void cmdRefresh_Click(object sender, EventArgs e)
            {       
                cmdRefresh.Enabled = false;
                lblErrMsg.Text = "Loading Data...";
                string errMsg = string.Empty;
                Debug.WriteLine("Refresh on PendingOrder Before PopulatePendingOrder");


                    GetPendingOrders work = new GetPendingOrders(PopulatePendingOrder);      //async call has been done through delegete GetPendingOrders 
                    AsyncCallback CompleteCallBack = new AsyncCallback(ShwPendngOrder);  //async call has been done through ShwPendngOrder

                    work.BeginInvoke(ref mobjQuery, ref errMsg, CompleteCallBack, null);


                Debug.WriteLine("Refresh on PendingOrder call completed PopulatePendingOrder");


            }
     


           //In this Function PopulatePendingOrder, Datatable gets updated bound to datasource of farpoint spread
            public Boolean PopulatePendingOrder(ref clsClientQueries objQuery, ref string msg)
            {
                msg = "";


                try
                {
                    Debug.WriteLine("Entry PopulatePendingOrders");
                    mobjQuery = objQuery;
                    mobjQuery.GetPartQueries();


                    if (mobjQuery.BuySellInd == clsConstantsEnums.gstrConstBuy)
                    {
                        //only buy
                        mobjQuery.ShowResults(mobjQuery.BuySellInd);


                    }
                    else if (mobjQuery.BuySellInd == clsConstantsEnums.gstrConstSell)
                    {
                        //only sell
                        mobjQuery.ShowResults(mobjQuery.BuySellInd);
                    }
                    else
                    {
                        mobjQuery.ShowResults(clsConstantsEnums.gstrConstBuy);
                        mobjQuery.ShowResults(clsConstantsEnums.gstrConstSell);


                    }


                   
                    Debug.WriteLine("exitting PopulatePendingOrders");
                    if (mobjQuery.BuyPendOrd.Count == 0 && mobjQuery.SellPendOrd.Count == 0)
                    {


                        msg = "No Data Found";
                        return false;
                    }
                    else
                    {


                        return true;
                    }


                }
                catch (Exception ex)
                {
                    clsBALCommon.gobjclsFunction.LogInformation(clsConstantsEnums.EnumLogFOR.LOGTWS, "frmPendingOrders-PopulatePendingOrder", string.Empty, ex, string.Empty, clsConstantsEnums.EnumCriticality.Critical, clsConstantsEnums.EnumRespOutputColor.Red, string.Empty, clsConstantsEnums.EnumRequestType.EXCEPTION);
                    throw ex;
                }


            }


    //This is async call back...in which EndInvoke returns if datatable gets updated successfully or not..if successful open the following form else dont ope nthe form
            public void ShwPendngOrder(IAsyncResult result)
            {
                string msg = "";
                Debug.WriteLine("Callback completed PopulatePendingTrades");
                AsyncResult ar = (AsyncResult)result;
                GetPendingOrders work = (GetPendingOrders)ar.AsyncDelegate;
                Boolean isSuccessful = work.EndInvoke(ref mobjQuery, ref msg, result);
                isSucessFull(isSuccessful, msg);


            }


           


           


         public delegate  void delNoDataFound(bool isVal, string msg);
            public void isSucessFull(bool isVal, string msg)
            {
                if (isVal == true)
                {
                    OpenPendingOrder();
                }
                else
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new delNoDataFound(isSucessFull), isVal, msg);
                        return;
                    }
                    //this.lblError.Text = msg;
                    this.lblErrMsg.Text = msg;
                }
                cmdRefresh.Enabled = true;
            }


            public delegate void delOpenPendingOrder();
            public void OpenPendingOrder()
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new delOpenPendingOrder(OpenPendingOrder));
                    return;
                }
                Debug.WriteLine("showing PendingOrder");
                this.lblErrMsg.Text = string.Empty;
                //InitializePendOrder();
                ShowPendingOrder();
                //gobjPendingOrder.Show();
                //this.Hide();
                //frmClientQueryClosing();
            }


    ************************************************************************************************************************************************************** 

  • Replied 8 September 2017, 1:16 pm EST

    Hi


    I have downloaded the latest version of Farpoint from the link you gave.But the problem persists.Same red X is displayed on spread if I go on refreshing the the farpoint spread.


    As I have used asynchronous delegate in my project,the query is run on the separate thread and when it is executed sucessfully,the callbak function is called.In that callback function datatable  is again bound to spread .For that purpose we have usesd Asynchrous Helper Class from codeproject.You can find it here:   


    http://www.codeproject.com/KB/threads/Asynchronousity.aspx


    We have used Async OI call on UI from this project.

  • Replied 8 September 2017, 1:16 pm EST

    Hello,

    I was not able to make out from your code what approach are you actually following to perform the update to th database. It would be a great help if you could provide me with a sample that depicts your approach and the exception that you are getting, so that I could look into the issue further.

    Thanks,

    Manpreet Kaur.

  • Replied 8 September 2017, 1:16 pm EST

    Dear Support,


    I am facing similar issue and i am getting this exception before getting Red X.


    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.


    ************** Exception Text **************
    System.Exception: Exception handled in FpSpread.WndProc ---> System.Exception: Exception handled in FpSpread.OnPaint() ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at FarPoint.Win.Spread.SpreadView.e(Graphics A_0)
       at FarPoint.Win.Spread.SpreadView.g(Graphics A_0)
       at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
       --- End of inner exception stack trace ---
       at FarPoint.Win.Spread.FpSpread.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
       at System.Windows.Forms.Control.WmPaint(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       --- End of inner exception stack trace ---
       at FarPoint.Win.Spread.FpSpread.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3623 (GDR.050727-3600)
        CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll


     


    I am working on a real time application and my grid needs to updates asynchronously since GUI may get freezed at times. It works in sync way like the GUI thread fetching data from database and then binding to grid. But my requirement is that i want to bind data asynchronously to grid.
    I am using C#.Net 2005,spwin4_net20-2009, SQL Lite 3.0. Attaching my code snippet for your reference. Expecting good support from you as always. Please revert if you have code snippet for async binding


    ************************************************************************************************************************************************************** 
            private void cmdRefresh_Click(object sender, EventArgs e)
            {      
                fpBuy.ShowCell(0, 0, 0, 0, FarPoint.Win.Spread.VerticalPosition.Top, FarPoint.Win.Spread.HorizontalPosition.Left);
                fpSell.ShowCell(0, 0, 0, 0, FarPoint.Win.Spread.VerticalPosition.Top, FarPoint.Win.Spread.HorizontalPosition.Left);
                cmdRefresh.Enabled = false;
                lblErrMsg.Text = "Loading Data...";
                string errMsg = string.Empty;
                Debug.WriteLine("Refresh on PendingOrder Before PopulatePendingOrder");


                    GetPendingOrders work = new GetPendingOrders(PopulatePendingOrder);
                    AsyncCallback CompleteCallBack = new AsyncCallback(ShwPendngOrder);
                    work.BeginInvoke(ref mobjQuery, ref errMsg, CompleteCallBack, null);


                Debug.WriteLine("Refresh on PendingOrder call completed PopulatePendingOrder");


            }
     
            public Boolean PopulatePendingOrder(ref clsClientQueries objQuery, ref string msg)
            {
                msg = "";


                try
                {
                    Debug.WriteLine("Entry PopulatePendingOrders");
                    mobjQuery = objQuery;
                    mobjQuery.GetPartQueries();


                    if (mobjQuery.BuySellInd == clsConstantsEnums.gstrConstBuy)
                    {
                        //only buy
                        mobjQuery.ShowResults(mobjQuery.BuySellInd);


                    }
                    else if (mobjQuery.BuySellInd == clsConstantsEnums.gstrConstSell)
                    {
                        //only sell
                        mobjQuery.ShowResults(mobjQuery.BuySellInd);
                    }
                    else
                    {
                        mobjQuery.ShowResults(clsConstantsEnums.gstrConstBuy);
                        mobjQuery.ShowResults(clsConstantsEnums.gstrConstSell);


                    }


                   
                    Debug.WriteLine("exitting PopulatePendingOrders");
                    if (mobjQuery.BuyPendOrd.Count == 0 && mobjQuery.SellPendOrd.Count == 0)
                    {


                        msg = "No Data Found";
                        return false;
                    }
                    else
                    {


                        return true;
                    }


                }
                catch (Exception ex)
                {
                    clsBALCommon.gobjclsFunction.LogInformation(clsConstantsEnums.EnumLogFOR.LOGTWS, "frmPendingOrders-PopulatePendingOrder", string.Empty, ex, string.Empty, clsConstantsEnums.EnumCriticality.Critical, clsConstantsEnums.EnumRespOutputColor.Red, string.Empty, clsConstantsEnums.EnumRequestType.EXCEPTION);
                    throw ex;
                }


            }



            public void ShwPendngOrder(IAsyncResult result)
            {
                string msg = "";
                Debug.WriteLine("Callback completed PopulatePendingTrades");
                AsyncResult ar = (AsyncResult)result;
                GetPendingOrders work = (GetPendingOrders)ar.AsyncDelegate;
                Boolean isSuccessful = work.EndInvoke(ref mobjQuery, ref msg, result);
                isSucessFull(isSuccessful, msg);


            }


            public delegate void delNoDataFound(bool isVal, string msg);
            public void isSucessFull(bool isVal, string msg)
            {
                if (isVal == true)
                {
                    OpenPendingOrder();
                }
                else
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new delNoDataFound(isSucessFull), isVal, msg);
                        return;
                    }
                    //this.lblError.Text = msg;
                    this.lblErrMsg.Text = msg;
                }
                cmdRefresh.Enabled = true;
            }


            public delegate void delOpenPendingOrder();
            public void OpenPendingOrder()
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new delOpenPendingOrder(OpenPendingOrder));
                    return;
                }
                Debug.WriteLine("showing PendingOrder");
                this.lblErrMsg.Text = string.Empty;
                //InitializePendOrder();
                ShowPendingOrder();
                //gobjPendingOrder.Show();
                //this.Hide();
                //frmClientQueryClosing();
            }


    ************************************************************************************************************************************************************** 


     


    Thanks,
    Sanket 


     

  • Replied 8 September 2017, 1:16 pm EST

    Hello,

    I went through the link provided by you and I was able to get an overview of the approach you are following. But I would need a sample depicting the issue that you are facing to assist you further with the same. Please provide me with a sample.

    Thanks,

    Manpreet Kaur.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels