-2

I am working on C# Windows app that reads data from SQL database and shows it in datagridview. I have printDocument1 imported to my form and print button that prints data from datagridview. I made it using a code from this page: https://www.codeproject.com/Articles/28046/Printing-of-DataGridView

It works like a charm but I need one more option: currently when form loads it fills up datagridview with data of a certain record. Pressing print button will print datagridview with current record. Pressing next button will fill up datagridview with data of next record.... it's all working. I just need somehow (after pressing PRINT ALL button) to print all the records from my database all together. I just can't figure out where to call a code which will refresh DGV with new data and loop through printing process...

Basically I want to print all the records from my DB and present it just like it is in DGV. I'm also using headers with current day in my printing so it needs to be in order with datas from DGV. any idea please?

1 Answers1

1

Use ObservableCollection for storing your data from db. It will track changes on the collection and will automatically refresh the view to which it is bound.

about the collection: What is the use of ObservableCollection in .net?

How to use with your datagridview: Binding ObservableCollection to DataGridView

Miraziz
  • 509
  • 7
  • 15