Welcome to the FoxLearn
Today we will learn how to print a datagridview with header and footer
First, We will design a simple UI that allows you to retrieve customer data from the Northwind database
You need to copy the DataGridView Printer to your project
You can download DataGridView Printer below this video
We will use entity framework to retrieve customer data from the northwind database
Entity Framework is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects
It eliminates the need for most of the dataaccess code that developers usually need to write
You need to add a binding source to your datagridview
The BindingSource component serves two purposes
First, it provides a layer of indirection when binding the controls on a form to data
This is accomplished by binding the BindingSource component to your data source, and then binding the controls on your form to the BindingSource component
All further interaction with the data, including navigating, sorting, filtering, and updating, is accomplished with calls to the BindingSource component
Second, the BindingSource component can act as a strongly typed data source
Adding a type to the BindingSource component with the Add method creates a list of that type
You can set a document's default page orientation to landscape through the PrintDocument.DefaultPageSettings property, and prints the document
Thank you for watching this video