Conditional Formatting for Textbox.Width

4 posts, 1 answers
  1. Joel
    Joel avatar
    174 posts
    Member since:
    Oct 2006

    Posted 14 May 2010 Link to this post

    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 ?

  2. Joel
    Joel avatar
    174 posts
    Member since:
    Oct 2006

    Posted 17 May 2010 Link to this post

    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 

  3. Answer
    Peter
    Admin
    Peter avatar
    1631 posts

    Posted 17 May 2010 Link to this post

    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.
  4. Joel
    Joel avatar
    174 posts
    Member since:
    Oct 2006

    Posted 17 May 2010 Link to this post

    Thank you.
Back to Top