打印Group Box的内容 [英] Print the contents of Group Box

查看:81
本文介绍了打印Group Box的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..



我有一个组合框和50个图片框,50个图片框都在组框内,我想要打印没有组合框的所有图片框,任何人都知道它的代码请与我分享...

i有它的示例代码,但我不知道下一步是什么,样本代码如下。

Hi..

I have one group-box and 50 picture box's,that 50 picture box's all are in-side of group box, i want to print the all picture box's without group box,any one know the code for it please share with me...
i have sample code for it but i don't know what the next step for this,the sample code is below.

var PictureBox = groupBox1.Controls.OfType<PictureBox>();
            foreach (PictureBox rb in PictureBox)
            {
               //string name = rb.Name;
            }





此代码仅显示图片框的名称,我想在一个按钮点击打印所有图片框没有组框...

帮我... ...



this code only show the picturebox's names,i want print the all picture box's without group box in one button click...
Help Me.....

推荐答案

查看 PictureBox.Image [ ^ ]属性 - 很明显它返回的是什么! :笑:



打印它是另一回事 - 你究竟是怎么做的取决于你认为打印的东西。如果您使用的是 PrintDocument Class [ ^ ]然后你需要使用其中一个 Graphics.DrawImage [ ^ ]重载实际将图像打印到提供的图形上下文。
Look at the PictureBox.Image[^] property - it's pretty obvious what it returns! :laugh:

Printing it is another matter though - exactly how you do it depends on what you consider "printing". If you are using the PrintDocument Class[^] then you need to use one of the Graphics.DrawImage[^] overloads to actually print the image onto the supplied graphics context.


我解决了这个问题...

我的代码如下...

I solve this problem...
my code is below...
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            int he = 0;
            int we = 0;
            int i = 15;
            int ch = 0;
            int count = 0;
///////////////////////////////////////////////////////////////////////////////////////////
            var PictureBox = groupBox1.Controls.OfType<PictureBox>();
            foreach (PictureBox rb in PictureBox)
            {
                for (ch = 0; ch < 1; ch++)
                {
                    count += 1;
                    if (count <= int.Parse(txtqty.Text))//txtqty=picture box Quantity
                    {
                        Bitmap bmpa = new Bitmap(rb.ClientRectangle.Width, rb.ClientRectangle.Height);
                        rb.DrawToBitmap(bmpa, rb.ClientRectangle);
                        e.Graphics.DrawImage(bmpa, he, we);
                        he = he + 100 + i;
                    }
                }
                we += 55;
                he = 0;
             }
///////////////////////////////////////////////////////////////////////////////////////////
        }

        private void button2_Click(object sender, EventArgs e)
        {           

            foreach (Control ctrl in groupBox1.Controls)
            {
                if (ctrl is PictureBox)
                {
                    printDocument1.PrintPage += this.printDocument1_PrintPage;
                    PrintDialog dlgSettings = new PrintDialog();
                    dlgSettings.Document = printDocument1;
                    if (dlgSettings.ShowDialog() == DialogResult.OK)
                    {
                        printDocument1.Print();
                    }
                }
            }
}







:))




:)


这篇关于打印Group Box的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆