Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change position of a field in crystal reports through vb.net

Status
Not open for further replies.

swetham

Programmer
May 5, 2010
257
DE
Is it possible to change x,y,width,height of a parameter field in crystal reports through vb.net code?
 

I believe you can do it like this:

Dim rpt As MyReport

rpt.Section3.ReportObjects("Field1").<Left>|<Top>|<Height>|<Width>

Get the field you want by name from ReportObjects, and that field has the properties of Left, Top, Height and Width. Note that you have to use the Section of the report. You can also use the report already in a Crystal Viewer control:

CRViewer1.ReportSource.Section8.ReportObjects("Field13").Left = 1150


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
I am getting error near the arrow,the code is

Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Public Class Form1
Public cryRpt As New ReportDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

load_report()
End Sub
Public Function load_report()
Try
cryRpt.Load("\\10.4.160.231\db\Reports\BSS.rpt")
gen_report()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Function
Public Function gen_report()
Try
Dim A As Integer = 2
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
With crConnectionInfo
.ServerName = "images"
.DatabaseName = "BBS.mdb"
.UserID = ""
.Password = ""
End With

CrTables = cryRpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues

crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields

crParameterFieldLocation = crParameterFieldDefinitions.Item("A")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = A
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

->CrystalReportViewer1.ReportSource.details.ReportObjects("A").Left = 1150



Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Function


End Class



The eroor is "object variable or with block variable not set". I have placed the parameter field "A" in the details section.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top