Programmatically Hide Ribbon


https://www.nevron.com/Forum/Topic13183.aspx
Print Topic | Close Window

By Ashley Davy - 3 Years Ago
Is there a way to programmatically hide the ribbon when using the NDrawingViewWithRibbonControl (at some point I just want to see the drawing surface)?  If not how would I transfer the drawing on the current NDrawingViewWithRibbonControl to another NDrawingViewControl?

Thanks,
Ashley
By Nevron Support - 3 Years Ago
Hi,

To hide the ribbon of a drawing view with ribbon control, you can use the following piece of code to first get the ribbon and then set its Visibility to collapsed:
  • C# Code

NRibbon ribbon = drawingViewWithRibbon.GetFirstDescendant<NRibbon>();
ribbon.Visibility = ENVisibility.Collapsed;

  • Visual Basic Code

Dim ribbon As NRibbon = drawingViewWithRibbon.GetFirstDescendant(Of NRibbon)()
ribbon.Visibility = ENVisibility.Collapsed

By Ashley Davy - 3 Years Ago
The code that was suggested shows errors.  The class NDrawingViewWithRibbonControl does not have a direct method call GetFirstDescendant.  I also tried the following code but the ribbon is return as null.

Dim ribbon As NRibbon = Draw1.View.GetFirstDescendant(Of NRibbon)()
   ribbon.Visibility = ENVisibility.Collapsed

Thanks,
Ashley
By Ashley Davy - 3 Years Ago
Hello,
I could not get the sample code you gave to compile.  I had to change it to the following.  However when I run this code the ribbon variable is null.  Please advise on what I need to do to hide the ribbon programmatically.  Draw1 is a NDrawingViewWithRibbonControl.

Thanks,
Ashley

Dim ribbon As NRibbon = Draw1.View.GetFirstDescendant(Of NRibbon)()
   ribbon.Visibility = ENVisibility.Collapsed

By Nevron Support - 3 Years Ago
Hi Ashley,

Indeed the code included a shortcut function that is not present in the current release. This must work with 2019.1:

   NRibbon ribbon = nDrawingViewWithRibbonControl1.Widget.GetFirstDescendant<NRibbon>();
    ribbon.Visibility = ENVisibility.Collapsed;

We hope this helps - let us know if you meet any problems.