Some help pelease
Error line 48
If is value null error
{"Object reference not set to an instance of an object."}
System.NullReferenceException
System.Windows. Forms.DataGridViewCelll.Value.get returned null
Some help?
- private void pdfButton_Click(object sender, EventArgs e)
- {
-
- PdfPTable pdfTable = new PdfPTable(prijava_radnikaDataGridView.ColumnCount -1);
- pdfTable.DefaultCell.Padding = 3;
- pdfTable.WidthPercentage = 100;
- pdfTable.HorizontalAlignment = Element.ALIGN_CENTER;
- pdfTable.DefaultCell.BorderWidth = 1;
-
-
- BaseFont bfCalibri = BaseFont.CreateFont("c:\\windows\\fonts\\calibri.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
- iTextSharp.text.Font calibri = new iTextSharp.text.Font(bfCalibri, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.WHITE);
- iTextSharp.text.Font calibri2 = new iTextSharp.text.Font(bfCalibri, 9);
-
-
-
- foreach (DataGridViewColumn column in prijava_radnikaDataGridView.Columns)
- {
-
-
- if (column.Index == 1)
- {
- }
- else
- {
- PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, calibri));
- cell.BackgroundColor = new BaseColor(89, 135, 178);
- cell.VerticalAlignment = Element.ALIGN_MIDDLE;
- pdfTable.AddCell(cell);
- }
- }
-
-
-
-
- foreach (DataGridViewRow row in prijava_radnikaDataGridView.Rows)
- {
-
- foreach (DataGridViewCell cell in row.Cells)
- {
- if (cell.ColumnIndex == 1 )
- {
- PdfPCell cell2 = new PdfPCell(new Phrase(cell.Value.ToString().Split(' ')[0], calibri));
- pdfTable.AddCell(cell2);
- }
- else
- {
- PdfPCell cell2 = new PdfPCell(new Phrase(cell.Value.ToString(), calibri));
- pdfTable.AddCell(cell2);
- }
-
- }
- }
- etc.....code....<<
- }