Solved

C# Printing a DataGrid

Posted on 2004-03-21
4
506 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to measure sizes and angles in scanned images ? 3 53
DateTimepicker 4 33
What .NET URL re-routing tool did I use? 2 37
Coding C# in Linux 8 33
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

19 Experts available now in Live!

Get 1:1 Help Now