There is no error showing. My selection is not working, I need to hide a specific field. If the field is empty the title of that field should be hidden. I am using a printpreviewdialog
to preview the details. my code:
private void DVPrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//e.Graphics.DrawString("NAME : " + dgvItem.CurrentRow.Cells[4].Value, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 400));
e.Graphics.DrawString("WEIGHT : " + txtGemWeight.Text + " Cts", new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 440));
//string txtSpecification = false;
if (txtSpecification.Text == null)
{
txtSpecification.Visible= false;
}
else
{
e.Graphics.DrawString("SPECIFICATION : " + txtSpecification.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, new Point(25, 480));
}
}
}
if(txtSpecification.Text == null)
change it to
if(txtSpecification.Text == "")
because text by default value is not null.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.