We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Suspend drawing of ribbon before SelectedTabItemChanged event is fired

Hello,

I have an application using RibbonControlAdv with multiple tabs on ribbon.

When I switch to tab, items on ribbon are changed. If tab has many items associated with it, redrawing will take a long time with intermediate states in between shown. I would like to suspend redrawing of ribbon for the time, however only related event I see is SelectedTabItemChanged, and that is after some of the redrawing was done, so it does not fix the issue.

What is the way to handle this issue?

7 Replies

ON Olety Nikhilesh Olety Nagendra Syncfusion Team July 24, 2019 02:35 PM UTC

Hi Rafal, 
 
Thank you for contacting Syncfusion support. 
 
We are still working on your requirement for “RibbonControlAdv with multiple tabs on ribbon” . We will analyze it properly and will provide you further details on July 26, 2019. 
 
We appreciate your patience until then. 
 
Regards, 
Nikhilesh O 



RP Rafal Pawlowski July 29, 2019 02:23 PM UTC

Hello,

Since July 26 has passed, can I get an update on this issue?


SP Subburaj Pandian Veluchamy Syncfusion Team July 30, 2019 11:01 AM UTC

Hi Rafal, 
  
We regret for the inconvenience caused. 
  
Based on the provided information, we understood that when switching tabs, the redrawing will take long time with intermediate states in between are shown. So, we made a workaround to lock the window update when drawing is been done in the RibbonPanel. Please find the code snippet below. 
  
        [DllImport("user32.dll")] 
        static extern bool LockWindowUpdate(IntPtr hWndLock); 
        public Form1() 
        { 
            InitializeComponent(); 
            for (int i = 0; i <this.ribbonControlAdv1.Header.MainItems.Count; i++) 
            { 
                (this.ribbonControlAdv1.Header.MainItems[i] asToolStripTabItem).Panel.VisibleChanged += Panel_VisibleChanged; 
            } 
            this.ribbonControlAdv1.SelectedTabItemChanged += RibbonControlAdv1_SelectedTabItemChanged; 
        } 
  
        private void Panel_VisibleChanged(object sender, EventArgs e) 
        { 
            LockWindowUpdate((sender as RibbonPanel).Handle); 
        } 
  
        private void RibbonControlAdv1_SelectedTabItemChanged(objectsender, SelectedTabChangedEventArgs e) 
        { 
            LockWindowUpdate(IntPtr.Zero); 
        } 
  
In the code snippet we have locked the drawing update of Ribbonpanel in the Panel visible changed and then released it in SelectedTabChanged event.  
 
We have prepared a simple sample for your reference, please find the sample by the following link. 
  
  
Please let us know if this approach resolves your issue or if you have any further queries. 
  
Regards,
Subburaj Pandian V  



RP Rafal Pawlowski July 30, 2019 12:45 PM UTC

Hello,

I have subscribed to VisibleChanged event on Panel in ToolStripTabItem:

item.Panel.VisibleChanged += Item_VisibleChanged;

Unfortunately it does not solve the issue - intermediate redraw happens before this event is fired and ribbon is locked in ugly state.

Please see attached archive. I have also provided a call stack from the moment Item_VisibleChanged handler breakpoint has been hit, as well as ribbon state in application.

Attachment: Pictures_cdfe509e.zip


SP Subburaj Pandian Veluchamy Syncfusion Team July 31, 2019 12:17 PM UTC

Hi Rafal, 
  
Thank you for the update. 
  
We understand that the provided event is invoked after the intermediate drawing and the ribbon is locked up.  There is an event in the ToolStripTabItem which fires after clicking a new tab and it may be useful to write your Suspend code.  
 
Please find the following code snippet, 
  
      foreach(ToolStripTabItem tabItem inthis.ribbonControlAdv1.Header.MainItems) 
            { 
               tabItem.CheckedChanged += TabItem_CheckedChanged; 
            }   
  
      private void TabItem_CheckedChanged(object sender, EventArgs e) 
        { 
          //Suspend Code 
        } 
  
We have prepared sample for the same for your reference, 
 
  
Can you please check whether this event is helpful in resolving your issue, if not we have planned to implement a new event “SelectedTabItemChanging” which invokes just after clicking a new tab. Based on your confirmation, we will implement the same. 
  
Please let us know if you have any concern on this. 
  
Regards,
Subburaj Pandian V     



RP Rafal Pawlowski August 2, 2019 12:33 PM UTC

So if I understand suspend/resume code would look like this:

        private void TabItem_CheckedChanged(object sender, EventArgs e)
        {
               LockWindowUpdate((sender as ToolStripTabItem).Panel.Handle);
        }

        private void RibbonControlAdv1_SelectedTabItemChanged(object sender, SelectedTabChangedEventArgs e)
        {
               LockWindowUpdate(IntPtr.Zero);
        }

Is this correct?


SP Subburaj Pandian Veluchamy Syncfusion Team August 5, 2019 09:34 AM UTC

Hi Rafal,  
   
Thank you for the update. Yes, suspend/resume code will work as you mentioned. 
 
Please let us know, if you would require any further assistance. 
 
Regards,
Subburaj Pandian V  


Loader.
Live Chat Icon For mobile
Up arrow icon