如何隐藏打印预览中的文本条目c#

时间:2018-05-06 23:21:04

标签: c#

没有错误显示。我的选择不起作用,我需要隐藏一个特定的字段。如果该字段为空,则应隐藏该字段的标题。 我使用printpreviewdialog来预览详细信息。 我的代码:

 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));
        }
    }
}

1 个答案:

答案 0 :(得分:0)

if(txtSpecification.Text == "")

将其更改为

@foreach($users as $user)
{{$user->name}}  {{$user->roles->first()->name}}

@endforeach

因为默认情况下的文本值不为空。