Textbox rotation or display horizontal vs vertical
Is it possible to align a text box to display text with rotation? For example can I display it rotated 90 degrees leftso that it reads from the bottom towards the top of the page? All I can find is left/right alignment and top/middle/bottom alignment. I want to rotate the text. Thanks.
June 21st, 2006 12:08am

You can use the WritingMode property (sometimes just labeled Mode)of a textbox to determine whether it is written vertically (tb-rl)or horizontally (lr-tb). See if the property documentation onhttp://msdn2.microsoft.com/en-us/ms189363.aspxhelps.
Free Windows Admin Tool Kit Click here and download it now
June 21st, 2006 1:20am

Thanks... thats almost it. But the text I want the text to read the other direction. tb-rl is the choice.. but i want it to be tb-lr. Is that possible? Thanks
June 21st, 2006 4:44pm

1Dave, This is something that I have been working on in vs2005. It hasn't been tested in Reporting Services but it should give you a direction to go in. To display text rotated 90 to the left in reportviewer: 1. Go to the Report Menu and Select Report Properties. 2. Select the References Tab. 3. Add a reference under assembly name to System.Drawing 4. Click on the code Tab. 5. Add the following Code: Function LoadImage(ByVal sImageText as String) sImageText= sImageText.PadRight(50) & " |" Change this as needed Dim iFontSize As Integer = 10 Change this as needed Dim bmpImage As New Drawing.Bitmap(1, 1) Dim iWidth As Integer = 0 Dim iHeight As Integer = 0 '// Create the Font object for the image text drawing. Dim MyFont As New Drawing.Font("Courier New", iFontSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point) '// Create a graphics object to measure the text's width and height. 'Graphics(MyGraphics = Graphics.FromImage(bmpImage)) Dim MyGraphics As Drawing.Graphics = Drawing.Graphics.FromImage(bmpImage) '// This is where the bitmap size is determined. iWidth = MyGraphics.MeasureString(sImageText, MyFont).Width iHeight = MyGraphics.MeasureString(sImageText, MyFont).Height '// Create the bmpImage again with the correct size for the text and font. 'bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iWidth, iHeight)) bmpImage = New Drawing.Bitmap(bmpImage, New Drawing.Size(iHeight, iWidth)) '// Add the colors to the new bitmap. MyGraphics = Drawing.Graphics.FromImage(bmpImage) MyGraphics.Clear(Drawing.Color.White) MyGraphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias MyGraphics.TranslateTransform(0, iWidth) MyGraphics.RotateTransform(270) MyGraphics.DrawString(sImageText, MyFont, New Drawing.SolidBrush(Drawing.Color.Black), 0, 0) MyGraphics.Flush() Dim stream As IO.MemoryStream = New IO.MemoryStream Dim bitmapBytes As Byte() 'Create bitmap bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg) bitmapBytes = stream.ToArray stream.Close() bmpImage.Dispose() Return bitmapBytes End Function 6. Click ok to save and close the Report Properties. 7. You may use a textbox or image control on your form to display the rotated text. 8. For a textbox you need to set the BackgroundImage properties, for both the image control and textbox set the following: Source = Database MIMEType = image/jpeg 9. To assign the text to be rotated to the control just set: Value = Code.LoadImage("Your Text Here!") or Value = Code.LoadImage(Fields!FirstName.Value) 10. If you are calling the Reportviewer Report from a form you need to add the following code to your form load event: Me.ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bla bla bla") You need to copy the assembly info from your Report Properties References tab for this to work. Let me know if you have any questions.
Free Windows Admin Tool Kit Click here and download it now
July 17th, 2006 5:08pm

i am unsure of where "Report Properties" are located. could you shed some light?
March 1st, 2007 8:44pm

Rightclick in the background of the report (in the reports layout) and select properties. Jens K. Suessmeyer. ---http://www.sqlserver2005.de---
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2007 6:44pm

I have a similar requirement andhave tried the solution which uv suggested .. but it doesnt work for me yet Is there anything else which needs to be taken care of ?
June 25th, 2007 9:27am

No, the solution should work like a charme, what is your problem. Do you get an error message ? BTW, the feature was posted by me on the connect.microsoft.com portal to vote for. If you find this one interesting and important, vote for it :-)Jens K. Suessmeyer.---http://www.sqlserver2005.de---
Free Windows Admin Tool Kit Click here and download it now
June 25th, 2007 10:11am

I need to incline the text in the textbox. I have tried the solution which has been posted in the thread (i.e creating the function ).. yet when i try to call the function, it gives me an Error and doesnt work .. do you have any inputs ?
June 26th, 2007 12:55pm

More details, which error ?Jens K. Suessmeyer.---http://www.sqlserver2005.de---
Free Windows Admin Tool Kit Click here and download it now
June 26th, 2007 8:44pm

I get the error at runtime : The report references the code module System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, which is not a trusted assembly. So I added ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bla bla bla");to my pageload...but i still get the error
July 18th, 2007 7:10pm

worked great. thank you
Free Windows Admin Tool Kit Click here and download it now
August 1st, 2007 12:35am

I followed teh steps outlined but I receive the following error: [rsCompilerErrorInCode] There is an error on line 12 of custom code: [BC30002] Type 'Drawing.Bitmap' is not defined. Could anyone help me with this? I am not a developer per se, just a simple report writer. Thanks much!
October 25th, 2007 6:09pm

I work with Visual Studio 2003 and the solution works for me. Thank You I hope that will be fixed in the futur version of Reporting Services
Free Windows Admin Tool Kit Click here and download it now
December 5th, 2007 7:09pm

I get the following warning when I try to use this to display static text:Warning 1 [rsInvalidExpressionDataType] The Value expression used in textbox textbox5 returned a data type that is not valid.It displays #Error on the rendered output.In the expression I have the following:=Code.LoadImage("text")Not sure what I am doing wrong.....
May 2nd, 2008 4:49pm

I tried this and recieve the error that Drawing.Bitmap is not defined how do I fix this
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2008 2:20am

I added the reference and pasted the code in the right place. I typed = Code.LoadImage("Test") in Value. Source as Database. MIMEType as image/jpeg and BackgroundRepeat as NoRepeat. I didn't get any errors but I get a dash (-) and no image or text. Please someone help. Thanks.
May 12th, 2008 8:37pm

I bet the dash is the | from the padding line in the code. Try making you text box larger.
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2008 8:55pm

I did, it didn't help. The dash is not |, it is -
May 12th, 2008 9:02pm

Comment out this line like so:'sImageText= sImageText.PadRight(50) & " |" Change this as neededLet me know if you are getting the same thing after?
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2008 9:10pm

Thanks, it worked.
May 13th, 2008 5:14pm

I'm having the same problem with #Error in the output. Does anyone have a fix for this?Thanks!Matt
Free Windows Admin Tool Kit Click here and download it now
August 11th, 2008 9:12pm

Dont put =Code.LoadImage("Text") in the textbox's value property. Place it in the Textbox's Background Image's Value (in coding terms it's TextBox.BackgroundImage.Value. That said, I'm still not THAT satisfied with the result due to the fact that the text is a little blurred. But still, thats not the designer's fault. It's the GDI's. Thanks for the hint.
August 29th, 2008 1:12pm

Thank you for the solution. It's really working for me. But I am having a problem when exporting this report to excel. The excel is not showing the rotated text.But it is working fine when i export to pdf.Can anyone help me in this isuue?
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2008 1:16pm

When I rotate text, some portion of image was not visible, so used trigonometry to calculate imagte size: I used following function to rotate text: Function RotateImage(ByVal bm_in As System.Drawing.Bitmap, ByVal RotationAngle As Integer) As System.Drawing.Bitmap Dim wid As Single = bm_in.Width Dim hgt As Single = bm_in.Height Dim corners As System.Drawing.Point() = { _ New System.Drawing.Point(0, 0), _ New System.Drawing.Point(wid, 0), _ New System.Drawing.Point(0, hgt), _ New System.Drawing.Point(wid, hgt)} ' Translate to center the bounding box at the origin. Dim cx As Single = wid / 2 Dim cy As Single = hgt / 2 Dim i As Long For i = 0 To 3 corners(i).X -= cx corners(i).Y -= cy Next i ' Rotate. Dim theta As Single = Single.Parse(RotationAngle) * System.Math.PI _ / 180.0 Dim sin_theta As Single = System.Math.Sin(theta) Dim cos_theta As Single = System.Math.Cos(theta) Dim X As Single Dim Y As Single For i = 0 To 3 X = corners(i).X Y = corners(i).Y corners(i).X = X * cos_theta + Y * sin_theta corners(i).Y = -X * sin_theta + Y * cos_theta Next i ' Translate so X >= 0 and Y >=0 for all corners. Dim xmin As Single = corners(0).X Dim ymin As Single = corners(0).Y For i = 1 To 3 If xmin > corners(i).X Then xmin = corners(i).X If ymin > corners(i).Y Then ymin = corners(i).Y Next i For i = 0 To 3 corners(i).X -= xmin corners(i).Y -= ymin Next i ' Create an output Bitmap and Graphics object. Dim bm_out As New System.Drawing.Bitmap(CInt(-2 * xmin), CInt(-2 * _ ymin)) Dim gr_out As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bm_out) ' Drop the last corner lest we confuse DrawImage, ' which expects an array of three corners. ReDim Preserve corners(2) ' Draw the result onto the output Bitmap. gr_out.Clear(Drawing.Color.White) gr_out.DrawImage(bm_in, corners) gr_out.Flush() ' Display the result. Return bm_out End FunctionWhole article is available here:http://tejasp.blogspot.com/2009/01/ssrs-reports-rotate-text-or-split.html
February 2nd, 2009 5:56am

Thanx it is working Fine.but when im exporting this report into excel that image disappears(Vertical Text Column).Plz Provide Help ..Abdul
Free Windows Admin Tool Kit Click here and download it now
February 4th, 2009 8:05am

HossHold_em said: I get the following warning when I try to use this to display static text:Warning 1 [rsInvalidExpressionDataType] The Value expression used in textbox textbox5 returned a data type that is not valid.It displays #Error on the rendered output.In the expression I have the following:=Code.LoadImage("text")Not sure what I am doing wrong.....plz.. make sure you don't forget the "End Function" line.. (at the end of the function)
February 12th, 2009 9:12pm

Worked great for me after I read all the amendments: 1. followed your directions2. commented out "'sImageText= sImageText.PadRight(50) & " |" Change this as needed"3. used <TableCell> <ReportItems> <Textbox Name="textbox43">... <Style>...<BackgroundImage> <Value>=Code.LoadImage("textValue")</Value> <Source>Database</Source> <BackgroundRepeat>NoRepeat</BackgroundRepeat> <MIMEType>image/jpeg</MIMEType> </BackgroundImage>... </Style> <Value /> </Textbox> </ReportItems> </TableCell> I love it when it works! Thanks for the help
Free Windows Admin Tool Kit Click here and download it now
March 5th, 2009 9:38pm

Hi, I have followed the same process. but i got the following error."Error while loading code module: System.Drawing. Details: Could not load file or assembly 'System.Drawing' or one of its dependencies. The system cannot find the file specified."what i need to do.I also tried the following:1 . by commenting the line --> sImageText= sImageText.PadRight(50) & " |" 2. entered the --> Code.LoadImage("Ordered") in BackgroundImage value and text value. But the error retains..
March 23rd, 2009 4:57pm

did you add the reference to System.Drawing ?1. Go to the Report Menu and Select Report Properties.2. Select the References Tab.3. Add a reference under assembly name to System.Drawing
Free Windows Admin Tool Kit Click here and download it now
March 23rd, 2009 5:48pm

I do not understand how to add a text-box to a line-chart and have it display the values (dates) of the x-axis If Access charts can do this, Crimey!, why is it so difficult in SSRS?Frank K
October 26th, 2009 8:06pm

Thanks. It did work, butcould not use it as the user wouldn't have the ability to copy the cell value, if needed.Its a shame that the problem is still open and we can't get it working just by setting a property!
Free Windows Admin Tool Kit Click here and download it now
November 18th, 2009 5:39pm

its not working for me. compile time error: The BackgroundImageValue for the text box ‘textbox41’ has a constant value. BackgroundImageValue requires a binary value, so it cannot be a constant.
January 27th, 2011 3:00am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics