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

Field position from database

4 Answers 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fridli Jacober
Top achievements
Rank 1
Fridli Jacober asked on 13 Jul 2010, 12:32 PM
hi

is it possible to set the position of an item with a value from the database?
we want to let the users set where the logo and the address block is positioned.

I tried this but it does not seem to work:

Me.HtmlTextBox1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(CDbl("=Fields.Settings_List_AdresseX"), Telerik.Reporting.Drawing.UnitType.Cm), [...])

With (for testing)
SELECT [...], 10 AS Settings_List_AdresseX FROM  [dbo].[...]

Thanks for help

4 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 15 Jul 2010, 01:41 PM
Hi Roland Meier,

You cannot use an expression to set a report item's location property directly, instead you can set the Location with the help of Bindings and an User Function as the one shown in the following code snippet:

public static Telerik.Reporting.Drawing.PointU location(double d)
{
    return new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(d, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(d, Telerik.Reporting.Drawing.UnitType.Inch));
}

Binding:

Property Path  Expression
------------------------------------------------------------------------------------
Location =location(Fields.Settings_List_AdresseX)

Check out the attached sample report. I have used a Report Parameter to set a TextBox's location with Bindings and User 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
Fridli Jacober
Top achievements
Rank 1
answered on 16 Jul 2010, 08:49 AM
Hi Peter

Thanks for your help. Sounds great but I have problems with the code.
I have:
KursAufgebot.vb
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports Telerik.Reporting
Imports Telerik.Reporting.Drawing
  
Partial Public Class KursAufgebot
    Inherits Telerik.Reporting.Report
  
    Public Sub New()
        InitializeComponent()
        Dim ReportParameter1 As Telerik.Reporting.ReportParameter = New Telerik.Reporting.ReportParameter
        Dim ReportParameter2 As Telerik.Reporting.ReportParameter = New Telerik.Reporting.ReportParameter
        ReportParameter1.Name = "sprache"
        ReportParameter1.Text = "sprache"
        ReportParameter1.Value = "<de>"
        ReportParameter2.Name = "AdFObjectID"
        ReportParameter2.Text = "AdFObjectID"
        ReportParameter2.Value = "..."
        Me.ReportParameters.Add(ReportParameter1)
        Me.ReportParameters.Add(ReportParameter2)
    End Sub
  
    Public Shared Function setLocation(ByVal x As Double) As Telerik.Reporting.Drawing.PointU
        Return New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(x, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm))
    End Function
End Class

and
KursAufgebot.Designer.vb
[...]
Me.HtmlTextBox1.Bindings.Add(New Telerik.Reporting.Binding("Location", "=setLocation(10)"))
        Me.HtmlTextBox1.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(0.31999999284744263, Telerik.Reporting.Drawing.UnitType.Cm))
        Me.HtmlTextBox1.Name = "HtmlTextBox1"
        Me.HtmlTextBox1.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(6.9000000953674316, Telerik.Reporting.Drawing.UnitType.Cm), New Telerik.Reporting.Drawing.Unit(2.1999998092651367, Telerik.Reporting.Drawing.UnitType.Cm))
        resources.ApplyResources(Me.HtmlTextBox1, "HtmlTextBox1")
[...]

This causes the following error in preview:
An error has occured while processing HtmlTextBox 'HtmlTextBox1':
The expression contains undefined function call setLocation().

I think I did the same as you did in your files (with the difference its vb.net not c#)
Can you see what I do wrong?

Thanks a lot
Roland
0
Peter
Telerik team
answered on 20 Jul 2010, 06:31 AM
Hello Roland Meier,

Your User Function expects Double while you are providing Integer data type thus the reporting engine is looking for an User Function setLocation(ByVal x As Integer). To avoid this you have to use the build in cast function CDbl() in the Bindings Expression: setLocation(CDbl(10))

Kind regards,
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
Fridli Jacober
Top achievements
Rank 1
answered on 22 Jul 2010, 05:51 AM
works great - thanks!
Tags
General Discussions
Asked by
Fridli Jacober
Top achievements
Rank 1
Answers by
Peter
Telerik team
Fridli Jacober
Top achievements
Rank 1
Share this question
or