Bounds cannot be changed while locked

10 posts, 0 answers
  1. Ching-Yen
    Ching-Yen avatar
    65 posts
    Member since:
    Nov 2007

    Posted 24 Jul 2008 Link to this post

    Hi,

    For sometime, we are facing error code as below during app loading

    Bounds cannot be changed while locked.(Telerik.WinControls)


                ' Place docking Pane
    39:         _LeftDock = New _PaneLeft()


    But, if we kill the application and restart, then the issue won't be appear...

    Please advice.

  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 25 Jul 2008 Link to this post

    Hi Ching-Yen,

    I was able to reproduce it. Currently, we are not quite sure what is the exactly cause for that.

    It would help us if you send us a simple example to reproduce problem locally. Thank you in advance.

    Sincerely yours,
    Julian Benkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ching-Yen
    Ching-Yen avatar
    65 posts
    Member since:
    Nov 2007

    Posted 25 Jul 2008 Link to this post

    Hi,

    Do you mean you able to reproduce it rite?

    Another issue is...the issue does not appear consistently in my big project too... I have no clue how to reproduce it on a simple project.
  5. Angel
    Admin
    Angel avatar
    121 posts

    Posted 28 Jul 2008 Link to this post

    Hello Ching-Yen,

    Thank you for writing.

    This sounds like a multithreading issue.
    The exception is shown when something in the layout is modified from a thread different than the painting one.
    In the current implementation we lock the layout while painting to avoid glitches caused by animations or user code.

    We intend to make our controls more thread-safe and user friendly in multithreading scenarios in the future.
    However, this task is non-trivial and I cannot give you a timeframe when it will be done.

    Meanwhile, you will have to avoid direct access of methods and properties from threads different than the main UI thread. In order to ensure the call is in the stack of the UI thread, you have to use Invoke() or BeginInvoke().
    There is a good article in the CodeProject on the subject.

    If you have further questions do not hesitate to write us.

    All the best,
    Angel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Arulanandham
    Arulanandham avatar
    1 posts
    Member since:
    Feb 2011

    Posted 09 Jan 2012 Link to this post

    Hi,

    We are using Q2 2010(.713) version for our application. We have faced the same problem in our application also.

    System.InvalidOperationException: Bounds cannot be changed while locked.

    at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)

    at Telerik.WinControls.RadElement.set_Bounds(Rectangle value)

    at Telerik.WinControls.UI.RadTreeView.DoLayout()

    at Telerik.WinControls.UI.RadTreeView.OnLayout(LayoutEventArgs args)

    at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)

    at System.Windows.Forms.Control.PerformLayout()

    at Telerik.WinControls.UI.RadTreeView.InvalidateLayout()

    at Telerik.WinControls.UI.RadTreeView.CollapseAll(RadTreeNodeCollection nodes)

    at Telerik.WinControls.UI.RadTreeView.CollapseAll()

    And we have used in the UI thread only. Could you please help me how to avoid these error in this version?

    Also Please clarify that whether it is good to suppressed the below exception?

     

    Thanks

    Arul

  7. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 12 Jan 2012 Link to this post

    Hello Arulanandham,

    Thank you for contacting us.

    We can not reproduce the issue by following your information. Please give us a more detailed description of used scenario, threads and synchronization logic. A simple application that demonstrates the issues will be greatly appreciated.

    Please note that you have to open a new support ticket in order to be able to attach your files.

    Also, please keep in mind that this version of RadTreeView control uses some part of old layout system and calculation. My advice is to upgrade your application to last Q3 2011 SP1 release and use the new version of RadTreeView control that contains greater functionality and improvements, new data engine, new layout system - flexible and customizable node elements.

    I am looking forward to your reply.

    Regards,
    Julian Benkov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  8. Will
    Will avatar
    11 posts
    Member since:
    Apr 2013

    Posted 30 Jul 2013 Link to this post

    Has anybody been able to fix this?  I'm seeing the same exception when I try to update a RadGridView.

    Here is my exception:

    Inner Exception 1
    Type=System.InvalidOperationException
    Source=Telerik.WinControls
    Message=Bounds cannot be changed while locked.
    StackTrace:
       at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)
       at Telerik.WinControls.RadElement.set_Size(Size value)
       at Telerik.WinControls.RadElement.SetLayoutParams(PointF newOffset, SizeF newSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.RowsContainerElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeViewElement(RectangleF viewElementRect)
       at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
       at Telerik.WinControls.RadElement.UpdateLayout()
       at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
       at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
       at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
       at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
       at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
       at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
       at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
       at Telerik.WinControls.Data.RadDataView`1.SyncCurrent(TDataItem item)
       at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
       at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
       at Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates)
       at Telerik.WinControls.Data.RadListSource`1.Initialize()
       at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
       at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
       at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
       at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
       at MyProject.MyWindow.<>c__DisplayClass2.<DisplayCallerInfo>b__0()

  9. Tim
    Tim avatar
    10 posts
    Member since:
    Apr 2012

    Posted 30 Jul 2013 Link to this post

    Has this been resolved?  I am seeing this exception when trying to update a RadGridView:

    Type=System.InvalidOperationException
    Source=Telerik.WinControls
    Message=Bounds cannot be changed while locked.
    StackTrace:
       at Telerik.WinControls.RadElement.SetBoundsCore(Rectangle bounds)
       at Telerik.WinControls.RadElement.set_Size(Size value)
       at Telerik.WinControls.RadElement.SetLayoutParams(PointF newOffset, SizeF newSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.RowsContainerElement.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeViewElement(RectangleF viewElementRect)
       at Telerik.WinControls.UI.ScrollViewElement`1.ArrangeOverride(SizeF finalSize)
       at Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
       at Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
       at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
       at Telerik.WinControls.RadElement.UpdateLayout()
       at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
       at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
       at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
       at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
       at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
       at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
       at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
       at Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
       at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
       at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
       at Telerik.WinControls.Data.RadDataView`1.SyncCurrent(TDataItem item)
       at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
       at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
       at Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates)
       at Telerik.WinControls.Data.RadListSource`1.Initialize()
       at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
       at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
       at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
       at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
       at MyProject.MyWindow.<>c__DisplayClass2.<DisplayCallerInfo>b__0()
  10. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 02 Aug 2013 Link to this post

    Hello Will and Tim,

    Thank you for writing.

    This error indicates that the grid is not in valid state. I noticed in the error stack that you update the datasource and this probably is asynchronously (another thread or timer). I would like to clarify that all UI controls are not thread safe controls in the whole Windows Forms UI platform. Here is an
    article on MSDN describing how to make thread-safe Winforms UI application. This means that RadGridView is not thread safe as well and cannot be used outside the main UI thread. In case that you are using a Timer from the System.Timers namespace you should know that this runs in the ThreadPool and your application will always produce cross-thread exception in the context of GUI. You should change the Timer object to System.Windows.Forms timer that runs in the same main thread and use it to implement the desired behavior. Also, you should use an Invoke to update the controls in cross threading scenario. For example:
    if (radGridView1.InvokeRequired)
    {
        radGridView1.Invoke(new MethodInvoker(() => { radGridView1.DataSource = myResults; }));//or change here something in the underlay datasource
    }
    else
       radGridView1.DataSource = myResults;
    }

    I hope this helps.

    Regards,
    Author nickname
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS. 
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>

      Regards,
    Peter
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  11. Tim
    Tim avatar
    10 posts
    Member since:
    Apr 2012

    Posted 08 Aug 2013 Link to this post

    Thanks Peter!
Back to Top
UI for WinForms is Visual Studio 2017 Ready