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

Conditional Formatting for Textbox.Width

3 Answers 405 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Joel asked on 14 May 2010, 04:20 PM
I have a report that looks as follows in the detail section, with the X's being the equivalent of a single line "bar chart".

Sales             XXXXXXXXXXXXXXXXX     75%
Research      XXXXXX                            20%
IT                   X                                      5%


The report is already done and in production except for the "x's", which the customer has now requested.  I looked at charting which I had used for something similar when it first came out and that solution no longer works, and the data binding seems quite inefficient using  needdatasource for each instance for numbers I already have in the detail section

Is there a way to use conditional formatting to control the width of a textbox based off something like txtBar.Width = Fields.Pct x 2 ?

3 Answers, 1 is accepted

Sort by
0
Joel
Top achievements
Rank 2
answered on 17 May 2010, 02:12 PM
I have an update on this, but receiving some odd behavior.  Using ItemDataBound, I can control the width of the text box.  Unfortunately, it appears to take effect on the NEXT detail line, not the current line?  Any suggestions?

I was originally using the value from the percentage box at the end of the line and thought the behavior was because the boxes were processed sequentially.  To test this I put a small hidden text box to the left of the bar and am using that as the value, but it exhibits the same behavior.


    Private Sub TextBox4_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox4.ItemDataBound 
        Dim procTextBox = TryCast(sender, Telerik.Reporting.Processing.TextBox) 
        Dim myval As Double 
        myval = CDbl(procTextBox.Value.ToString) 
        txtBar.Width = Drawing.Unit.Pixel(myval * 100) 
    End Sub 

0
Accepted
Peter
Telerik team
answered on 17 May 2010, 03:39 PM
Hello Joel,

To conditionally control the TextBox item width, you can either:

1. Set the TextBox width in a Event as you have tried. Unfortunately you have set the width to a report definition item instead to a processing one. Check out the following help articles:
Understanding Events
Report Life Cycle

2. Set the width property with a Binding to an User Function as shown in following code snippet:

Public Shared Function RunTimeWidth(value As String) As Telerik.Reporting.Drawing.Unit
    Return Unit.Pixel(CDbl(value) * 100)
End Function

Best wishes,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joel
Top achievements
Rank 2
answered on 17 May 2010, 06:10 PM
Thank you.
Tags
General Discussions
Asked by
Joel
Top achievements
Rank 2
Answers by
Joel
Top achievements
Rank 2
Peter
Telerik team
Share this question
or