Collapsing CommandBarStripElement

9 posts, 0 answers
  1. pierre-jean
    pierre-jean avatar
    91 posts
    Member since:
    Apr 2011

    Posted 02 Nov Link to this post

    Hello

    I have a Command bar with one row and three StripElements
    Depending on some condition I wish to programmatically set the second strip element to visible or collapsed.
    When I change the visibility property of the second strip element from Visible to Collapsed it is no longer visible but the third strip element does not move against the first strip, an empty space remains between the first end the third strip.

    Also I have set the grip and overflow visibility to collapsed on all three strip elements.

    How can I "force" the collapsing to occur ?

    Thanks in advance

    PJ

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 04 Nov Link to this post

    Hello, Pierre-Jean,         

    The described behavior is expected. Note that the CommandBarStripElement's position depends on its DesiredLocation property value. Hence, you collapse the second CommandBarStripElement, the DesiredLocation of the third CommandBarStripElement should be adjusted to the location of the hidden strip element: 

                this.commandBarStripElement2.Visibility = ElementVisibility.Collapsed;
                this.commandBarStripElement3.DesiredLocation = this.commandBarStripElement2.Location;

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. pierre-jean
    pierre-jean avatar
    91 posts
    Member since:
    Apr 2011

    Posted 04 Nov in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks for your message

    Unfortunately I have not managed to get it to work.
    I have created a test program with 4 CommandBarStrips (all4 have grip and overflow buttons set to collapsed)

    And I have added two buttons one to show all 4 Strip Elements enad one to show strips 1,2 and 4, i.e. to hide strip 3 and have strip 4 next to strip 2

    Here is the code behind the two buttons (which to me follows your suggestion)

    --------------------------------------------------------------------------------------------------------------------------------------
        Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
            'show 1,2,3,4
            CommandBarStripElement1.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement2.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement3.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement4.Visibility = Telerik.WinControls.ElementVisibility.Visible
        End Sub
        Private Sub RadButton3_Click(sender As Object, e As EventArgs) Handles RadButton3.Click
            'show 1,2,4 hide 3
            CommandBarStripElement1.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement2.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement3.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            CommandBarStripElement4.Visibility = Telerik.WinControls.ElementVisibility.Visible
            CommandBarStripElement4.DesiredLocation = CommandBarStripElement3.Location
        End Sub

    --------------------------------------------------------------------------------------------------------------------
    The attached compilation of screen shots shows the effect
    1. Initial state : Correct, i.e. Strip 1, 2 3 and 4 in the original order
    2. After click on Button "Show 1,2,4" I have strips 1,4,2 Strip 3 is correctly hidden but strip 4 should be after strip 2 not before
    3. After clic on Button Show 1,2,3,4 Where I owuld expect to have the 4 strips in teh order 1,2,3,4 I have Strip 1, 2, 4 and 3

    I have tried many combinations but never gor the correct behavior

    I nust be missing something but I fail to see what

    Thanks in advance

    PJ

     

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 05 Nov Link to this post

    Hello, Pierre-Jean, 

    According to the provided explanation and screenshot, I was able to modify my sample project and replicate the undesired behavior that you are facing. This is because the CommandBarStripElement3.Location property is PointF(0,0). This makes CommandBarStripElement4.DesiredLocation to be before all other strip elements except CommandBarStripElement1 which also wants to be placed at PointF(0,0). You can use the CommandBarStripElement3.DesiredLocation
    I have updated my sample project which result is illustrated in the attached gif file. Please refer to the provided attachment.

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. pierre-jean
    pierre-jean avatar
    91 posts
    Member since:
    Apr 2011

    Posted 05 Nov in reply to pierre-jean Link to this post

    Hello and thanks for your message

    Your sample project does indeed work as desired

    Hoever when I implement the same in my project (which is in VB) It does not work.

    Clicking on Button "Show 1,2,4" hides strip 3 but does not move strip 4 next to strip 2
    Actually it behaves exactly in the same way as in your programm when I change Collapsed to Hidden on Strip 3 

    Is there a Bug whan used in VB.Net ???

    Here below my vb Code

    ----------------------------------------------------------------------------------------------

        Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
            'show 1,2,3,4
            CommandBarStripElement1.Visibility = ElementVisibility.Visible
            CommandBarStripElement2.Visibility = ElementVisibility.Visible
            CommandBarStripElement3.Visibility = ElementVisibility.Visible
            CommandBarStripElement4.Visibility = ElementVisibility.Visible
        End Sub
        Private Sub RadButton3_Click(sender As Object, e As EventArgs) Handles RadButton3.Click
            'show 1,2,4 hide 3
            CommandBarStripElement1.Visibility = ElementVisibility.Visible
            CommandBarStripElement2.Visibility = ElementVisibility.Visible
            CommandBarStripElement3.Visibility = ElementVisibility.Collapsed
            CommandBarStripElement4.Visibility = ElementVisibility.Visible
            CommandBarStripElement4.DesiredLocation = New System.Drawing.PointF(CommandBarStripElement3.DesiredLocation.X, CommandBarStripElement3.DesiredLocation.Y)
        End Sub
    -----------------------------------------------

  6. pierre-jean
    pierre-jean avatar
    91 posts
    Member since:
    Apr 2011

    Posted 05 Nov in reply to pierre-jean Link to this post

    Hello

    I think that I have finally put the fnger on the origine of the problem.

    The erroneous positionning of the strip element, when the previous one is collapsed, occurs when the Monitor Display parameter is set to a value different from 100%.

    As it happens I was running your test application on a PC set to 100% and my application is on a PC with a 4K display set to 150%
    as soon as I set it to 100% the positioning is correct. 

    I hope this info can be usefull to others.

    Anyway I do not understand why I have to programmatically redefine the desiredposition, I would expect the control to automatically reset the position when a stripelement is set to collapsed; as such I dont see the difference between Hidden and Collapsed other than the fact that I can reposition in Collapsed mode and not in Hidden Mode.

    I would appreciate an explanation and eventually take this as a suggestion for improvement, may be with the addition of a property "AutoCollapse"

    In any case I thank you for the time you have spent on this issue

    best regards

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 06 Nov Link to this post

    Hello, Pierre-Jean, 

    RadCommandBar is not expected to automatically move its strip elements to the left if you collapse certain strip elements. 

    Indeed, when you run the project on higher than 100% DPI scaling, CommandBarStripElement4 is not placed next to CommandBarStripElement2 with the previous solution. This is because the getter of the DesiredLocation property returns the scaled location. However, the setter expects a value that is not scaled. That is why you need to descale the DesiredLocation value first. Please refer to he below code snippet:
                PointF descaled = TelerikDpiHelper.DescalePointF(this.commandBarStripElement3.DesiredLocation, this.commandBarRowElement1.DpiScaleFactor);
                this.commandBarStripElement4.DesiredLocation = descaled;

    Please give it a try and see how it works on your end.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  8. pierre-jean
    pierre-jean avatar
    91 posts
    Member since:
    Apr 2011

    Posted 06 Nov in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you

    indeed this works

    I have also managed to get a proper behavior by changes in the manifest and appconfig files, these changes also correct some minor incorrect displays when in 150%. Here are the changes I made:

    1. Manifest - cemmented the following:
      <!--<application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
          <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
        </windowsSettings>
      </application>-->

    2.. in App.config: added the following:
      <appSettings>
        <add key="EnableWindowsFormsHighDpiAutoResizing" value="false"/>
        <add key="ClientSettingsProvider.ServiceUri" value=""/>
      </appSettings>
     <System.Windows.Forms.ApplicationConfigurationSection>
      <add key="DpiAwareness" value="PerMonitorV2" />
    </System.Windows.Forms.ApplicationConfigurationSection>

    and I have set the AutoScaleMode property of the form to DPI

    Thanks again

    PJ


     

  9. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3451 posts

    Posted 11 Nov Link to this post

    Hello, Pierre-Jean, 

    I am glad that the problem you were facing is now resolved.

    Note that Telerik UI for WinForms suite offers built-in HDPI support. With the changes we are introducing, the common problem of bad scaling when your applications run on high resolution monitors goes away, so your app will ship with higher quality on more systems instantly.

    Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/dpi-support 

    Should you have further questions please let me know.

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top