Preserve white space when hiding textbox in rdlc f

2019-06-19 01:49发布

问题:

I've created a report that has an image on the left that is conditionally visible based on a parameter that's passed in to the report. There is another textbox on the right side of the page.

I'm observing that when the image's Hidden property is set to "True" then the textbox on the right side stays in the right place. When the image's Hidden property is set to =IFF(1 = 1, true, true), then the textbox on the right is being shifted to the left, and the report looks ugly.

How can I have the hidden object still take up all the necessary space, and set it as hidden with an expression?

回答1:

To prevent the behaviour that you are seeing, you can place some other object (like rectangle or a line) onto your designer in the same location as your image and have it take up the same horizontal space as the image on the left.

When the image is hidden, this object will remain there and prevent the right side textbox from moving.

I would keep this object visible in the designer and set its colour to match your background colour (e.g., White) during runtime so that you don't see it.

I would also give it some descriptive name like LineWhichPreventsTextBoxFromMovingWhenImageIsHidden so that some future maintainer of the report does not inadvertently remove it and thus cause a breaking change.



回答2:

In case of textbox, setting the value conditionally saved me from putting placeholder object like the answer suggested. An example code =IIF(First(Fields!SlNo.Value) > 1 , "", First(Fields!MacType.Value)) This might help someone.