FpScrollBar.TimerTick

Posted by: darcy_rainey on 8 September 2017, 2:33 pm EST

  • Posted 8 September 2017, 2:33 pm EST

    I have come across a situation that will consistently raise an exception.

    In my Windows Forms desktop application I make extensive use of FpSpread. On some forms, in the handler for the Models.Data.Changed event I remove the existing SheetView and replace it with a new one. This works fine in most situations. However, if the user changes a value in a cell then uses the mouse to click to 'up' button on the vertical scrollbar (with the cell still in edit mode) I get the following exception:

    System.ArgumentOutOfRangeException: The value is not valid; the value must be between the minimum and maximum values.
    Parameter name: Value
    Actual value was -1.
       at FarPoint.Win.Spread.FpScrollBar.c(Int32 A_0)
       at FarPoint.Win.Spread.FpScrollBar.TimerTick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    I can reproduce this behavior in a very simple application (without timers). My workaround is to start a timer with a 200 millisecond interval in the Models.Data.Changed event handler and have the timers Tick event handler replace the SheetView. Any advice or comments on this would be welcome.

    Here is the full stack trace:

    System.ArgumentOutOfRangeException: The value is not valid; the value must be between the minimum and maximum values.
    Parameter name: Value
    Actual value was -1.
       at FarPoint.Win.Spread.FpScrollBar.c(Int32 A_0)
       at FarPoint.Win.Spread.FpScrollBar.TimerTick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.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.4952 (win7RTMGDR.050727-4900)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    FpScrollErr
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Dev/Apps/Vs2010/FpScrollErr/bin/Release/FpScrollErr.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    FarPoint.Win.Spread
        Assembly Version: 4.0.3503.2008
        Win32 Version: 4.0.3503.2008
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/FarPoint.Win.Spread/4.0.3503.2008__327c3516b1b18457/FarPoint.Win.Spread.dll
    ----------------------------------------
    FarPoint.Win
        Assembly Version: 4.0.3503.2008
        Win32 Version: 4.0.3503.2008
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/FarPoint.Win/4.0.3503.2008__327c3516b1b18457/FarPoint.Win.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    FarPoint.CalcEngine
        Assembly Version: 4.0.3503.2008
        Win32 Version: 4.0.3503.2008
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/FarPoint.CalcEngine/4.0.3503.2008__327c3516b1b18457/FarPoint.CalcEngine.dll
    ----------------------------------------

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:


       


    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.



  • Replied 8 September 2017, 2:33 pm EST

    Hello,

    Could you please let me know what code are you using to replace the SheetView?

     

    Thanks,

     

  • Replied 8 September 2017, 2:33 pm EST

    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;

    using FarPoint.Win.Spread;
    using FarPoint.Win.Spread.CellType;
    using FarPoint.Win.Spread.Model;

    namespace FpScrollErr {

      public partial class Form1 : Form {

        private FpSpread c_grid;
        private List m_vals;

        public Form1() {
          InitializeComponent();

          c_grid = new FpSpread();
          c_grid.Dock = DockStyle.Fill;

          this.Controls.Add( c_grid );

          this.Load += new EventHandler( Dlg_Load );
        }

        private void Dlg_Load( object sender, EventArgs e ) {
          m_vals = new List();
          for ( int val = 0; val < 25; val++ )
            m_vals.Add( val );

          LoadSheet();
        }

        private void LoadSheet() {
          SheetView gridSheet = new SheetView();
          gridSheet.RowHeader.ColumnCount = 0;

          gridSheet.ColumnCount = 1;
          gridSheet.Columns[0].CellType = new NumberCellType();

          int row = 0;
          gridSheet.RowCount = 0;

          foreach ( double val in m_vals ) {
            gridSheet.RowCount += 1;
            gridSheet.Cells[row, 0].Value = val;
            row += 1;
          }

          c_grid.Sheets.Clear();
          c_grid.Sheets.Add( gridSheet );
          gridSheet.Models.Data.Changed += new SheetDataModelEventHandler( Data_Changed );
        }

        private void Data_Changed( object sender, SheetDataModelEventArgs e ) {
          SheetView curSheet = c_grid.ActiveSheet;
          if ( curSheet == null )
            return;

          double newVal = 0.0;
          if ( curSheet.Cells[e.Row, e.Column].Value != null )
            newVal = Convert.ToDouble( curSheet.Cells[e.Row, e.Column].Value );
          m_vals[e.Row] = newVal;

          LoadSheet();
        }

      }

    }

  • Replied 8 September 2017, 2:33 pm EST

    Hello,

    I am unable to replicate the issue with Spread for Win Forms version 4 latest build. From the exception I found that you are using pretty old build. However, I would request you to please upgrade your project to the latest build and share your observations then. You can get the latest build from this link:-ftp://ftp.fpoint.com/SpreadWinForms4/spwin4_net35-3526.zip

    Thanks.

     

  • Replied 8 September 2017, 2:33 pm EST

    Hi Reeva,

     

    The latest build solved the problem. Thanks!

Need extra support?

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

Learn More

Forum Channels