Is anyone printing winforms that contain datagridviews etc?

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 11-Sep-2006 17:09:37   

version 1.0.2005.1 final (self-servicing) VS2005 (pro) winforms


Hiya,

I have a winforms 2.0 app that will run locally.

The form that I need to print contains: 1) comboboxes, 2) textboxes 3) a datagridView.

Has anyone managed to use ReportViewer with llblGenPro winforms apps?

http://www.gotreportviewer.com/

The only alternative that I can see is the datgridviewPrinter class from codeProject.

http://www.codeproject.com/csharp/datagridviewprinter.asp

The haslle is that even if I get the datagridviewPrinter class working, I STILL have to figure out how to print the comboboxes and textboxes etc.

Can anyone suggest a way which worked for them?

many thanks,

yogi

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 11-Sep-2006 18:40:55   

Hi,

it seems that printing winforms content is not trivial, and there are several ways to it, with their pros and con:

Something quite trivial, make use of a screenshot thanks to "CopyFromScreen": the following code shows that:

http://msdn2.microsoft.com/en-us/library/6he9hz8c.aspx

Quite simple to set up, but then you have to enforce the form's appearance, and it's not so robust.

Then you have full features commercial solutions:

see http://www.winformreports.co.uk/ for instance (quite expensive)

Then you may turn to reporting solution (crystal/reporting services...)

So, coming back to your reportviewer.

I think you should be fine when you're done with the instructions provided on their website in "Defining Report Data Sources". LLBLGen's manual suggests how you can add such a DataSource to your project:

See the "Design time support in VS.NET 2005" section:

In the following explanation,

not only drag the EntityCollection onto your form but also a BindingSource control. You then set the DataGridView's DataSource property to the BindingSource control and the BindingSource' DataSource property to the EntityCollection dragged onto the form. The EntityCollection class then doesn't have a factory set so use the the smart-tag on the EntityCollection on the form to configure the collection which will show the EntityCollection's designer.

, you should be able to replace the datagrid view with your report

Hope that helps.

Actually, if that works ok, that can be fine to post some code here, to let other people know...

Cheers

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 12-Sep-2006 12:13:02   

hiya Jesse,

I think I'll use reportViewer.I'll send my progress.

thanks,

yogi.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 13-Sep-2006 16:37:40   

Ok, has anyone actually used reportViewer to succesfully view LlblGenPro data?

drag the EntityCollection onto your form drag a BindingSource control. You then set the DataGridView's DataSource property to the BindingSource control and the BindingSource' DataSource property to the EntityCollection dragged onto the form. The EntityCollection class then doesn't have a factory set so use the the smart-tag on the EntityCollection on the form to configure the collection which will show the EntityCollection's designer.

you should be able to replace the datagrid view with your report

the problem is that the report is SEPARATE from the winform. The new report that I create will not be aware of any winform specific datasources / bindingSources.

So, I added an entityCollection as a PROJECT datasource...

Data --> add new datasource --> object --> navigate to the correct entityCollection.

The correct entityCollection now appears in my project data sources.

I then create the report. The report displays, but only the headers, it doesn't display any details.

Maybe I have made a mistake in the above?

I suspect that the entityCollection is not being populated...Why, I don't know

I can confirm that I can:

1) use the entityCollection to programatically populate a gridView 2) use a standard .NET database datasource to get the data onto a test report. (from same database)

I notice a difference in the 2 different winforms:

NORMAL datasource winform report:


private void frmTableReport_Load(object sender, EventArgs e)
        {
          this.aspnet_MembershipTableAdapter.Fill(this.CSK2DataSet.aspnet_Membership);
          this.reportViewer1.RefreshReport();
        }

LlblGenPro datasource winform report:


private void frmLlblGen_Load(object sender, EventArgs e)
        {
            //WHY is there no code here to POPULATE the entityCollection?
            this.reportViewer1.RefreshReport();
        }

I can supply more details of course.I think I am nearly there.It would be nifty to get a walkThru of using a reportViewer for LlblGenPro.I could help to write it, but obviously I need to be able to work it first :-)

many thanks for any help.

yogi

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 14-Sep-2006 21:19:11   

Keep in mind that some report writers are really dumb when it comes to databinding: they just work with datasets and that's it. This could be the reason why no relations show up?

Frans Bouma | Lead developer LLBLGen Pro
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 17-Sep-2006 15:38:14   

hiya,

Ok, understood.I have vs2005 pro edition.I wanted to use reportViewer to create a report that mirrors a winform that I have already created...Basically, so that I can print it.

Is there no way that I can re-use the llblgenPro code to create this report?I'm really just looking for ways to minimise the amount of extra work that I'd have to do.

Many thanks,

yogi

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 18-Sep-2006 09:26:16   

It sometimes works when you setup the report with a dataset and then bind an entitycollection at runtime, or you could use dyn. lists etc.

Frans Bouma | Lead developer LLBLGen Pro
Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 18-Sep-2006 13:27:34   

I am not tested it yet; but maybe can help:

http://www.winformreports.co.uk/features_pf.htm

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 18-Sep-2006 20:30:34   

hiya,

Thanks for that Rogelio, but Ideally I'd like to be able to do it without using a 3rd party component.

It sometimes works when you setup the report with a dataset and then bind an entitycollection at runtime, or you could use dyn. lists etc.

Ok, let's say for example that I want to try and setup the report with a dataset.Do I somehow get hold of the generated sql from the entityCollection?I assume that this is what I must do, as it would contain all the relations etc?

many thanks,

yogi

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 19-Sep-2006 10:55:39   

yogiberr wrote:

hiya,

Thanks for that Rogelio, but Ideally I'd like to be able to do it without using a 3rd party component.

It sometimes works when you setup the report with a dataset and then bind an entitycollection at runtime, or you could use dyn. lists etc.

Ok, let's say for example that I want to try and setup the report with a dataset.Do I somehow get hold of the generated sql from the entityCollection?I assume that this is what I must do, as it would contain all the relations etc?

many thanks, yogi

I'm guessing here, but most of these things work with a typed dataset which you use to setup the fields and the like on the report, then at runtime you bind an entitycollection with the same fields. It's tricky though, and might not work with related entities. But if you can't use an entitycollection at runtime, I can't help you further, as the report control developer then didn't obey the standard databinding interfaces etc. disappointed (unfortunately, a lot of them don't... ). ActiveReports seems to work (I've heard)

Frans Bouma | Lead developer LLBLGen Pro
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 27-Dec-2006 16:06:12   

hiya,

I'm revisiting this thread because I'm being asked again to get this app printing. has there been any change in the new Llblgenpro version that will allow me to use "ReportViewer" or some other free component to print out the contents of my winform 2005 datagridViews etc?

I understand the issue was that a lot of the report designers didn't strictly follow the databinding guidelines..what I essentially need to do is print datagridView that contain entityCollections with a few relations...Is anyone out there doing it with a free component?

many thanks,

yogistuck_out_tongue_winking_eye

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Dec-2006 16:23:17   

My 2 cents (outside of LLBLGen Pro):

In the old days, I used to print WinForms or data through an HTML Viewer (browser). Simply by putting the data into an XML file, and by using a nicely designed XSL file the XML gets rendered in an HTML Viewer which you can show to the user as a preview window, and a print button would call it's print method. Or I think you can skip the viewing part and directly print it under the hood.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 28-Dec-2006 14:52:35   

Thanks Walaa,

At the moment, I am using the PrintDocument method, and prinitng a bitmap.However, as soon as the datagridView has more then a single page, then that's going to break.What html viewer do you use?

cheers,

yogi

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Dec-2006 08:50:43   
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 05-Jan-2007 12:47:05   

cheers Walaa.

I had forgotten all about webBrowser control.

yogi