Link to home
Start Free TrialLog in
Avatar of ekenman
ekenman

asked on

Drill down Reports. Using controls or drawing strings

I have several Window Forms that display economical reports in my application. Due to the lack of speed of adding controls when the form is created, I draw the report values in the pain event in the forms.

Now, I'd like to add a drill down function and wonder what's the best way to go about. The reports normally displayes about 20 rows in 12 columns, (sometimes up to 36 columns though), so there are quite a few values.

Is there a way to add controls to a form in a quicker way?

If this is not possible, I guess I have to make my own table of positions to determine where the mouse is and to change the cursor when it is over a drawn string. The easiest way I can think of is to have an array(formposX,formposY) containing null or drilldownvalue depending on the strings. Anyone have a better solution?

Thanks in advance

Tomas
Avatar of Mike McCracken
Mike McCracken

What reporting tool?

mlmcc
Avatar of ekenman

ASKER

No reporting tool, just Winform
/Tomas
Are you just painting some labels on the form? Paint event is not the best place to do so. Can you show us some code? Is using Crystal Reports a viable option for you? These come free with .NET
Avatar of ekenman

ASKER

CodeCruiser, I'm just painting text, no labels since it is to slow to add controls. When the user change an option in the report, there might be more fields to display, so Crystal will not do it for me.

Below is some of the code from the paint event. I also paint rectangles and headers, but it's done in the same manner.

Reportarray holds the values from my sql-data. Canvas is the forms painteventargs.

Best Regards

Tomas

            For Each item As Reportvalue In ReportArray
                If Not item Is Nothing Then
                    If item.Type <> ReportFieldType.CRLF Then
                        Dim temploc As Point
                        temploc.X = item.Location.X - hscrollpos - ColRightMargin
                        temploc.Y = item.Location.Y - vscrollpos
                        canvas.DrawString(item.Text, item.Font, Brushes.Black, temploc, format1)
                        temploc.X = item.Location.X - vscrollpos
 
                        If item.Type = ReportFieldType.CalculatedValue And item.Location.X = 342 Then
                            'Add a line
                            canvas.DrawLine(Pens.Black, 15 - hscrollpos, item.Location.Y - 2 - vscrollpos, (Reportperiods) * ColDistance + HeaderLeftMargin + HeaderWidth - 1 - hscrollpos, item.Location.Y - 2 - vscrollpos)
                        End If
                    End If
                End If
            Next

Open in new window

Then the way to implement drilldown is to store the bounds of each text in a collection and on mouse move event, you would be matching the current x, y with stored bounds and if it happens to be within the bounds of a drill down enabled field then change the cursor to hand. Same would go for mouse click event.
Avatar of ekenman

ASKER

So what kind of object would I use for the collection? Should I make my own object containing x,y, width and height and how do I compare it? Is there an object width a withinbounds method?
/Tomas
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial