views:

238

answers:

1

Hi, I am want to apply gradient color on textbox background in active report. For this I use graphics and use following code:

 Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New RectangleF(0, 0, Me.Width, Me.Height), color1, color2, mode)
        Dim g As Graphics = Me.CreateGraphics
        g.FillRectangle(a, New RectangleF(0, 0, Me.Width, Me.Height))
        g.Dispose()

It works well in forms but in report not able to get object of Graphics by Me.CreateGraphics. Please suggest

A: 

You can accomplish this in ActiveReports using Picture control. Just add a gradient image to the ActiveReports Picture control and place the picture control in the same location as the textbox. To account for the fact that the textbox may grow our shrink based on the data at runtime (due to the CanGrow and CanShrink properties) you should use the following code in the format event of the section containing the textbox & picture control:

public void Detail1_Format()
{
    this.gradientPicture.Height = this.txtCustomerID1.Height;   
}

FYI: The CreateGraphics technique you used is a Windows Forms specific way to do painting. In addition to working in windows forms, ActiveReports has to work in environments other than Windows Forms, so unfortunately we cannot use this exact technique with ActiveReports.

You can also draw onto an ActiveReports page using the DataDynamics.ActiveReports.Document.Page class in a similar way to the way you draw on a Graphics. Unfortunately, it is a bit tricky to map each textbox to it's corresponding position a every page which would be needed to draw the gradients on the textbox so I think the former solution is best.

I also entered an suggestion for the ActiveReports product management team to consider a feature to enable a better way to do this in the future. It will be tracked under case #142836.

I hope this is helpful!

scott