Problem in StripElement Visible/Collapsed

4 posts, 1 answers
  1. Franco
    Franco avatar
    27 posts
    Member since:
    Apr 2010

    Posted 18 Jan 2012 Link to this post

    Good morning.
        I have a CommandBar with 5 strips in it. Note I don't want users to rearrange the strips, so in my real project I removed this possibility. I run the project and I see all the 5 strips, see image1.png attached file. Now I set Visibility = ElementVisibility.Collapsed for strips 2, 3 and 5. The strip disappears but strip 4 stays where it is. So I try with strip4.DesiredLocation = Pointf.Empty, and the behavior is what I want (see image2.png). When I set Visibility = ElementVisibility.Visible again (for strips 2, 3 and 5), the order of the strips is messed up, and is 1, 2, 4, 3, 5, but I wanted to get them exactly in the previous order. How can I solve this problem?

    Thank you
    Gianfranco
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 Jan 2012 Link to this post

    Hello Franco,

    Thank you for writing.

    You should save the commandBarStripElement4's DesiredLocation before setting it to Point.Empty. Later, when showing back the strips, set the DesiredLocation property to the saved value:

    PointF saveLocation;
    private void radButton1_Click(object sender, EventArgs e)
    {
        commandBarStripElement2.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        commandBarStripElement3.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        commandBarStripElement5.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
        saveLocation = commandBarStripElement4.DesiredLocation;
        commandBarStripElement4.DesiredLocation = Point.Empty;
    }
     
    private void radButton2_Click(object sender, EventArgs e)
    {
        commandBarStripElement2.Visibility = Telerik.WinControls.ElementVisibility.Visible;
        commandBarStripElement3.Visibility = Telerik.WinControls.ElementVisibility.Visible;
        commandBarStripElement5.Visibility = Telerik.WinControls.ElementVisibility.Visible;
        commandBarStripElement4.DesiredLocation = saveLocation;
    }

    I hope this helps.

    Kind regards,
    Stefan
    the Telerik team

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

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Franco
    Franco avatar
    27 posts
    Member since:
    Apr 2010

    Posted 23 Jan 2012 Link to this post

    Ok, it works! Thank you very much.
    Gianfranco
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Jan 2012 Link to this post

    Hello Franco,

    You are welcome. If you have any other questions, do not hesitate to contact us.

    All the best,
    Stefan
    the Telerik team

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

Back to Top