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

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)