vb.net 报表查看器文本框可见性表达式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16110474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Report viewer textbox visibility expression
提问by NexAddo
I am trying to get a text box and tablix to toggle their visibility based on an expression.
我正在尝试使用文本框和 tablix 来根据表达式切换它们的可见性。
I have tried the following:
我尝试了以下方法:
=IIF(First(Fields!Supported.Value, "FooDataSet") = "true", True, False)
However, this will not work for me. I'm using the 2010 version and using it in local mode.
但是,这对我不起作用。我正在使用 2010 版本并在本地模式下使用它。
I also tried writing custom code to see if that would work:
我还尝试编写自定义代码以查看是否可行:
Public Function ToggleVisibility(ByVal visible As string) As Boolean
Dim isVisible As Boolean = False
If visible = "true" Then
isVisible = True
End If
Return isVisible
End Function
Then I use it in the "Show or hide based on an expression" under the Visibility item in the text box and tablix properties.
然后我在文本框和 tablix 属性中可见性项下的“根据表达式显示或隐藏”中使用它。
=Code.ToggleVisiblity(First(Fields!Supported.Value, "FooDataSet"))
This also does not work for me.
这对我也不起作用。
回答by Patrick D'Souza
I see the visibility for a textbox and it worked.
我看到了一个文本框的可见性并且它起作用了。
I did the following
我做了以下
- Right Clicked the textbox control
- Clicked Textbox Properties... => Visibility
- Selected show or hide based on an expression and clicked the fx button
- In the expression editor, I added the following code.
- 右键单击文本框控件
- 单击文本框属性... => 可见性
- 根据表达式选择显示或隐藏并单击 fx 按钮
- 在表达式编辑器中,我添加了以下代码。
=IIF(First(Fields!Author.Value, "DataSet1")="Romulus",true,false)
=IIF(First(Fields!Author.Value, "DataSet1")="Romulus",true,false)
Note in this editor, you are setting the expression for Hiddenand not Visibility, so be careful on passing the values. In my case since Romulus was not a Author, the condition was evaluated to falseand the textbox was visible
请注意,在此编辑器中,您正在设置Hidden而不是Visibility的表达式,因此在传递值时要小心。在我的情况下,由于 Romulus 不是作者,条件被评估为false并且文本框可见
回答by AmirHossein Manian
It should work even without IIF.
即使没有IIF.
=First(Fields!Supported.Value, "FooDataSet") = "true"

