BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
i use this code to achieve what i want
PdfExportingOptions GridPdfExportingOptions = new(); private PdfExportingOptions PdfExportingOptions() { SkipColumns(); return GridPdfExportingOptions; } private void SkipColumns() { if (ChkAddress.Checked) { GridPdfExportingOptions.ExcludeColumns.Add("Address"); } } private void Export_Click (object sender, EventArgs e) { var document = new PdfDocument(); document.PageSettings.Orientation = PdfPageOrientation.Landscape; var page = document.Pages.Add(); var PDFGrid = DGV_Student.ExportToPdfGrid( DGV_Student .View, PdfExportingOptions()); var format = new PdfGridLayoutFormat() { Layout = PdfLayoutType.Paginate, Break = PdfLayoutBreakType.FitPage }; PDFGrid.Draw(page, new PointF(), format); SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "PDF Files(*.pdf)|*.pdf" }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { using (Stream stream = saveFileDialog.OpenFile()) { document.Save(stream); } } } |
that code only works if the box is checked..
what i want is, the code should work when the box is checked and unchecked. how to achieve it?
Thanks :)
Hi RIDWAN,
We have checked the reported issue and found that once we added the column names to an ExcludeColumn list, then we should remove them from the ExcludeColumn list if you also want to export it. You can fix the problem by intialize the ExcludeColumns list while call the SkipColumns method or else remove the added column names from ExcludeColumns list. Refer to the below code snippets and a sample.
thanks for taking the time to answer my question, what you provided really worked. :)
Ridwan,
We are glad to know that the reported problem has been resolved at your end.
Please let us know if you have any further queries on this. We are happy to
help you😊.