Home Forums WinForms controls Xceed Grid for WinForms Exception when changing column visible property

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16391 |

    When trying to change the visible property of all the columns in the grid, I sometimes get the following exception:

    HorizontalSrollValue must be less than or equal to its Maximum value.
    Parameter name: HorizontalScrollValue
    Actual value was 10.:    at Xceed.Grid.ScrollManager.set_HorizontalScrollValue(Int32 value)
       at Xceed.Grid.PaintManager.CalculateGridRectangleAdjustedToScrollBar(Graphics graphics, Rectangle& gridRectangle)
       at Xceed.Grid.PaintManager.Update()
       at Xceed.Grid.PaintManager.GetGridClientRectangle()
       at Xceed.Grid.PaintManager.GetVisualGridElementAtPoint(Int32 x, Int32 y, Boolean excludeFixedColumnSplitter)
       at Xceed.Grid.GridControl.DoMouseMove(MouseEventArgs e)
       at Xceed.Grid.GridControl.OnMouseMove(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseMove(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Xceed.Grid.GridControl.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)

    This is a sample code that I’ve been using:

                    dataGrid.BeginInit();
                            foreach (Xceed.Grid.Column col in dataGrid.Columns)
                                      col.Visible = SomeFunctionToDetermineVisibility();
                    dataGrid.EndInit();

     Any ideas what might be wrong?

    Imported from legacy forums. Posted by Testing (had 956 views)

    User (Old forums)
    Member
    Post count: 23064

    Is there a way to override the ScrollManager class? Want to edit the set_HorizontalScrollValue so if the value is greater than the maximum value to use the maximun, but I can’t seem to find that class anywhere, not even in the doc files.

    Imported from legacy forums. Posted by Testing (had 594 views)

    User (Old forums)
    Member
    Post count: 23064

    Are you using multi-threading?  Are these calls sometimes initialize from another thread?

    It is not possible to override the ScrollManager.

    Imported from legacy forums. Posted by André (had 215 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Yes, I’m doing multi-threading, but they are properly isolated. The visibility call is done from the main UI Thread.  I think I have discover what the problem is actually. The problem happens when you are very far away in the scroll bar to the right hand side, and suddenly, from 100 visible cols, you change it to only to say a number, 3 visible cols. When the Paint event tries to repaint the grid, It won’t adjust the horizontal scroll position to reflect there are only 3 visible rows and will try to set it like the 100 cols are still there.

    What I did in the mean time then, it’s to override the paint event to catch the ArgyumentOutOfRangeException,   such as:

      protected sealed override void OnPaint(PaintEventArgs e)
            {
                try
                {
                    base.OnPaint(e);
                }
                catch (ArgumentOutOfRangeException)
                {
                    this.Scroll(ScrollDirection.LeftmostPage);
                    OnPaint(e);
                }
            }

     

    That solved the problem for now.

    Imported from legacy forums. Posted by Testing (had 442 views)

    User (Old forums)
    Member
    Post count: 23064

    We do not reproduce this in a sample application having 100 columns and 10 000 rows.  It scrolls back just fine to the left side of the grid when the number of visible columns is set back to 3.

    If you are entitle to support, and have a small sample application reproducing the issue, you can send us an email, and we will investigate this issue further.

     

    Imported from legacy forums. Posted by André (had 1072 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.