Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • read about Suggestion ID: CS47880 (hide only contained control of a LayoutControlItem)

                                    How can I hide the contained control of a LayoutControlItem (i.e. a button) without any change to the layout itself?
                                    Is there any Property like layoutControlItem.Control.Visible or layoutControlItem.ControlVisible (as is for Text)?

                                    How can I implement a workaround? (For example: overlay with an emptySpace)

                                ScreenshotLayoutControlItemBehaviour.xls
                                0

                                Hi Hans,

                                I believe that you can use the LayoutControlItem.Visibility property.
                                For example:
                                Me.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never
                                To obtain more information, please refer to the corresponding article in the help.

                                Thanks,
                                Andrew

                                0

                                Hi Andrew,
                                what you propose is exactly what I've done (see the screenshots in the attachment).
                                Unfortunately, the behaviour is not the desired one. By setting Visibility to "Never", hidden place will be overtaken by other items. What I need (...and as I read in the forum, other users do so...): the place of the hidden item must NOT be overtaken by other items. At the place of a hidden item (hidden control) should be something like an empty space.
                                Again, please look the attachment.

                                Regards,
                                Hans

                                0

                                Hi Hans,

                                Thank you for the feedback.
                                I've attached a sample illustrating how to accomplish this task.
                                Please let us know whether it meets your needs.

                                Thanks,
                                Andrew

                                Q100293.zip
                                0

                                Hi Andrew,
                                thanks for your sample which is nearly perfect.
                                I also experimented with layoutControlItem.Control.Visible but stated no effect. By your sample code, I know now, that these statements (and their sequence) are mandatory:

                                 // hide
                                 myLayoutControlItem.BeginInit();
                                 myControl.Visible = false;
                                 myLayoutControlItem.Control = null;
                                 myLayoutControlItem.TextVisible = false;
                                 myLayoutControlItem.EndInit();
                                 myLayoutControl.Refresh()

                                 // show
                                 myLayoutControlItem.BeginInit();
                                 myControl.Visible = true;
                                 myLayoutControlItem.Control = myControl;
                                 myLayoutControlItem.TextVisible = true;
                                 myLayoutControlItem.EndInit();
                                 myLayoutControl.Refresh()

                                I extended your sample application by some controls for testing purposes.
                                Also, I filled in my controls (and testing scenario). There are still some problems and I have no idea how to solve.
                                1. When I hide the OK- or Cancel-Button, the Action-Button modifies its size and the remaining visible button changes position. ???
                                2. When I change the text of OK- (or Cancel-) Button while it is not visible (hidden), the text will though be visible ???
                                (it seems as if TextVisible-property will automatically set to true on change to the Text-property ??!!)

                                hope to hear you soon,
                                regards, Hans

                                WindowsApplication1Modified.zip
                                0

                                Hello Hans,

                                Unfortunately, I cannot give an immediate answer to your question. We need some time to investigate the issue. We'll contact you as soon as possible.

                                Thank you,
                                Paul

                                0

                                Hello Hans,

                                You can use the following approach. Place the empty space items under each button, set its constraints type to custom and set the minimal height to 1. To hide an item, just set the lciCancel.Visibility to Never. Concerning the text visibility, I see from your code, you are making the text visible explicitly within the tbOkText_EditValueChanged event, for example.

                                Thank you,
                                Paul

                                WindowsApplication2.zip
                                0

                                Hi Paul,
                                thanks for your investigations. The issue with text visibility was really my fault. The problem is: When you set Text property to an empty string, then you will see the name of the LayoutControlItem and that's definitively not wanted. So I have to handle that.

                                Concerning the layout troubles I must state, that your proposed workaround only works, if each control is in a separate LayoutcontrolGroup and GroupBordersVisible property is true. On false, you'll find the same behaviour.

                                In the sample application we exchange, the effect is not evident (only a few pixel of misspositioning).
                                In (my) real live, these 3 controls form a custom user control and the effect is worse. When hiding the Cancel item, the Action item shrinks to its half. Don't know why ?

                                Seems to be hard work to hide/show controls !!!

                                hope to hear from you soon.
                                My local time is midnight now. I'll go home. Ciao

                                Regards, Hans

                                WindowsApplication1Modified2.zip
                                0

                                Hi Hans,
                                I have corrected your code (see below). Now it works as expected. We see that the XtraLayoutControl is not easy to use in the scenario you described. To simplify the process of hiding a layout control item's content, our developers are going to implement the LayoutControlItem.ContentVisible property.

                                protected void HideShowItemContent(LayoutControlItem bli, bool hide, Control control) {
                                            bli.BeginInit();
                                            if (hide)
                                                bli.Control = null;
                                            else
                                                bli.Control = control;
                                            bli.SizeConstraintsType = SizeConstraintsType.Custom;
                                            if (hide) {
                                                bli.SizeConstraintsType = SizeConstraintsType.Custom;
                                                bli.MinSize = bli.Size;
                                                bli.MaxSize = bli.Size;
                                            } else {
                                                bli.SizeConstraintsType = SizeConstraintsType.Default;
                                            }
                                            control.Visible = !hide;
                                            bli.TextVisible = !hide;
                                            bli.EndInit();
                                            layoutControlMain.Refresh();
                                        }
                                          private void ckOkVisible_CheckedChanged(object sender, EventArgs e)
                                          {
                                            HideShowItemContent(lciOk, ckOkVisible.Checked, bnOk);
                                          }
                                        private void tbOkText_EditValueChanged(object sender, EventArgs e) {
                                            lciOk.Text = tbOkText.Text;
                                        }

                                Thank you,
                                Roman K.

                                0

                                Hi Roman,
                                thanks again for your endeavour.
                                Have incorporated your code and .... nearly perfect.
                                It's really not easy, what should I say...
                                Look what will happen when you hide the Action-Button and then resize the form. The Ok- and Cancel-Button stay frozen instead of aligne to the right.
                                How can I achieve, that all controls will be layouted fine whether they are visible or hidden ?
                                I need the same layout behaviour as when the controls were visible.
                                That is:
                                - Ok- and Cancel-Button are right aligned and have fixe size (which of course depends of the text)
                                - Action-Button is left aligned and expands from the left until the Ok-Button

                                If the text of Ok- and Cancel-Button would not be variable, I would solve the layout by a TableLayoutPanel with 5 colums (Action-Button (100%), Ok-Text (?? Pixel), Ok-Button (23 Pixel), Cancel-Text (?? Pixel), Cancel-Button (23 Pixel).

                                Hope you find a way to solve this layout requirement also with the DevExpress LayoutControl.

                                Regards, Hans

                                0

                                Hello Hans,

                                You can achieve this task by adding empty items to the left of the desired layout items. Please refer to the attached sample.

                                Thank you,
                                Paul

                                dxSample.zip

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners