ssrs rotate (angle) of a textbox
Hi, I know you can rotate a text box to (270, vertical, ho..) but is it possible to rotate it in an angle? In reports when use the writeingMode and change it to 270 it does not "angle, sideway", is it possible to do so? Thanks
January 14th, 2011 5:59pm

hI, This is something that I haS Seen long time in the net and used it working on in vs2005 and saved it for me , don't have the link though. 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. Hope it works. Regards, PS
Free Windows Admin Tool Kit Click here and download it now
January 15th, 2011 2:02am

hI, This is something that I haS Seen long time in the net and used it working on in vs2005 and saved it for me , don't have the link though. 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. Hope it works. Regards, PS
January 15th, 2011 2:02am

Thank you so very much, I will try it out. Again, thanks for your time.
Free Windows Admin Tool Kit Click here and download it now
January 15th, 2011 12:14pm

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

Other recent topics Other recent topics