+ 1

What is the code for button (print ), to print information from the datagrid view ?

7th Feb 2021, 11:08 AM
Batoul Kharrouby
Batoul Kharrouby - avatar
3 odpowiedzi
+ 1
Can you choose the text approach. This one for one row. if (dataGridView2[col, ro].Value != null) theValue = dataGridView2[col, ro].Value.ToString(); else theValue = ""; https://social.msdn.microsoft.com/Forums/windows/en-US/a12c2711-7127-4a65-a0d3-e722bdefa074/how-to-get-the-text-from-datagridtextboxcolumn-in-datagridview-in-cnet?forum=winformsdatacontrols This one for all rows. foreach (DataGridViewRow row in dataGridView1.Rows) { var obj = new MyClass() { Nachricht = dataGridView1.row.Cells["Value"].Value.ToString(), Datum = dataGridView1.row.Cells["File"].Value.ToString() }; llist.Add(obj); } https://stackoverflow.com/questions/39418973/datagridview-get-values-from-all-rows
7th Feb 2021, 2:45 PM
sneeze
sneeze - avatar
+ 1
What should the button do ? Print to a printer Or Show the text on the screen Or Write the text to a file?
7th Feb 2021, 11:13 AM
sneeze
sneeze - avatar
+ 1
Using printDocument and printPreviewDialog from toolbox ,we need the code of the button (print) to print information from data grid view . I have tried a code but it printed from the textbox but i want to print from the data grid view
7th Feb 2021, 12:43 PM
Batoul Kharrouby
Batoul Kharrouby - avatar