我想直接打印Winform上TextBox、Label、ComboBox中的内容,但不要控件的边框,请问大家怎么实现?

解决方案 »

  1.   

    你写后台程序的时候,先获取控件内容,放入DATASET中,再打。如果LZ说要保持格式的话,就做个XML模板,调用XML方式进行打印
      

  2.   

    你可以设置控件的边框的类型。和设置控件的BackColor 和窗体的颜色一样。就可以达到你所要的效果。例如:
                  this.textBox1.BorderStyle = BorderStyle.None;
                this.comboBox1.FlatStyle = FlatStyle.Flat;
                this.textBox1.BackColor = Color.Control;     //和窗体的颜色一样
      

  3.   

    我需要直接打印控件中的文本内容。并且位置和控件所在位置一致。
    不想通过dataSet传到水晶报表或XML中打印。
      

  4.   

    我要具体的例子~比如用printDocument,怎么做?
      

  5.   

    知道了,谢谢大家~要用这个来做:
    private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
    {
        Pen blackPen = new Pen(Color.Black, 3);
        e.Graphics.DrawString(label1.Text, new Font("Monotype Corsiva", 50, FontStyle.Italic), Brushes.Black, 30, 30);
        e.Graphics.DrawString(textBox1.Text, new Font("Monotype Corsiva", 50, FontStyle.Italic), Brushes.Black, 30, 125);
        e.Graphics.DrawRectangle(blackPen, 20, 20, 300, 200);}private void btnPrint_Click(object sender, EventArgs e)
    {
        printDocument1.DefaultPageSettings.Landscape = true;
        printDocument1.Print();
    }
      

  6.   

    我发布的资源里有类似的一份源代码。也是给CSDN的网友类似问题写的DEMO。
      

  7.   

    我觉得还是比较爱哦简单的啊:
    //就这样循环下就可以了。
    foreach(Control ctrl in Form.Controls)
    {
        if(ctrl is 你限定的控件)
        {
            g.DrawString(ctrl.Text, Font, Brush, ctrl.Left, ctrl.Top);
        }
    }