本文介绍了printPreview if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我只想打印一些textBoxes和comboBoxes而不是所有这些我不能将打印作为图像使用。 我怎么能改变这一点,如果它不是0就会显示出来。 private void button2_Click( object sender,EventArgs e) { printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); } private void printDocument1_PrintPage_1( object sender,System.Drawing.Printing.PrintPageEventArgs e) { if (textBox1.Text = 0 ) e.Graphics.DrawString(textBox1.Text,textBox1.Font,Brushes.Black, 100 , 120 ); e.Graphics.DrawString(comboBox1.Text,comboBox1.Font,Brushes.Black, 100 , 100 ); } 解决方案 将if语句更改为: if (textBox1.Text.Length!= 0 )等 I only want to print some of the textBoxes and comboBoxes not all of them so I can''t use the print as an image.How can I change this so that if it isn''t 0 it will show it.private void button2_Click(object sender, EventArgs e) { printPreviewDialog1.Document = printDocument1; printPreviewDialog1.ShowDialog(); }private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e) { if (textBox1.Text = 0) e.Graphics.DrawString(textBox1.Text, textBox1.Font, Brushes.Black, 100, 120); e.Graphics.DrawString(comboBox1.Text, comboBox1.Font, Brushes.Black, 100, 100); } 解决方案 Change that if statement to this:if (textBox1.Text.Length != 0)etc 这篇关于printPreview if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-02 13:54