Solved

C# Printing a DataGrid

Posted on 2004-03-21
4
505 Views
Last Modified: 2012-05-04
Hello Expert is there an easy way to print the dataGrid when the user hits print on a Windows From  and only the columns that are visible not all the ones that are hidden?

Janka
0
Comment
Question by:jvoros1
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Joeisanerd
ID: 10645917
did you still want to print all of the rows? When you use a dataGrid and limit the number of columns to display it creates a dataview. You would then use that dataview to print only the data that is shown.

You could also use Crystal Reports to make the data layout look better for printing.
0
 

Author Comment

by:jvoros1
ID: 10645970
Do you have anywhere a sample of code to show me by any chance I am pretty new to C# and I never printed before.
0
 

Author Comment

by:jvoros1
ID: 10645976
this Is an example of my dataGrid binding
                  cs = new DataGridTextBoxColumn();
                  cs.MappingName = "PermitApprov";
                  cs.HeaderText = " Permit / Approve. Etc ";
                  cs.Width = 200;
                  cs.Alignment = HorizontalAlignment.Center;
                  tableStyle.GridColumnStyles.Add(cs);
                  dataGrid1.TableStyles.Add(tableStyle);

                  cs = new DataGridTextBoxColumn();
                  cs.MappingName = "UserID";
                  cs.HeaderText = " User ID";
                  cs.Width = 0;
                  cs.Alignment = HorizontalAlignment.Center;
                  //Sets the Default Value of userID
                  aDataSet.Tables["tbl_ProjectLogDrawingsInOut"].Columns["UserID"].DefaultValue = 0;
                  tableStyle.GridColumnStyles.Add(cs);
                  dataGrid1.TableStyles.Add(tableStyle);

                  dataGrid1.DataSource = aDataTable;
0
 
LVL 9

Accepted Solution

by:
glsac earned 500 total points
ID: 10646274
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now