This is a migrated thread and some comments may be shown as answers.

How to hide a text control?

5 Answers 428 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 20 Aug 2007, 06:09 PM
Hello -
I have a report in which has two textbox controls that are placed on the same spot on the report layout.  Only one can have a value at a time (rules handled by the app user interface and database). 

What I want to do is place them on top of each other in the desinger, but then only have one's Visible property set to True if it has data.

How can I do this with the Telerik reporting?  Unlike SSRS, there doesn't appear to be any expression builders.

Thanks,
 - will

5 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 21 Aug 2007, 01:45 PM
Hi Will,

To accomplish this task you should implement an event handler for the ItemDataBound event of the TextBoxes. It should look like the following:

                     using Processing = Telerik.Reporting.Processing;
         ...      
         private void textBox1_ItemDataBound(object sender, System.EventArgs e)
         {
              Processing.TextBox textBox = (Processing.TextBox)sender;
              textBox.Visible = !string.IsNullOrEmpty(textBox.Text);
         }

    

If needed, you can change the expression which determines the value of the Visible property of the TextBox.

Hope this helps. Let me know if you have any other questions regarding this issue.
 

Kind regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 21 Aug 2007, 03:13 PM
Hello again Chavdar -

Thanks for the information.  This helps a great deal.

Regards -
 Will
0
Will
Top achievements
Rank 1
answered on 22 Aug 2007, 06:48 AM
Hi,
I tried what you suggested, but I can't get it to work.  I added the ItemDataBound event for my two text controls and they are always visible.

Also, can you include an example in VB.Net?

Thanks
 - will
0
Chavdar
Telerik team
answered on 22 Aug 2007, 12:34 PM
Hi Will,

Here is the method body in VB.NET:

    Dim textBox As Processing.TextBox = DirectCast(sender, Processing.TextBox)
    textBox.Visible = Not String.IsNullOrEmpty(textBox.Text)


Make sure that the event handler is executed correctly by setting a break point in it and running the application in debug mode. If the break point is not hit then it is possible that the event handler is not attached properly to the event. If the break point is hit then check what value is returned by the expression for the Visible property of the TextBox. It might happen that the value is true for both Textboxes.

If it is still not working, please, open a support ticket and send us the report definition so that we can look at it locally.
 

Sincerely yours,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 22 Aug 2007, 09:56 PM
Hey again,

Thanks for the code sample and help.  This works great now.

 - will
Tags
General Discussions
Asked by
Will
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Will
Top achievements
Rank 1
Share this question
or