本文介绍了如何保持在一个标签控件一个图片的图形描绘切换到选项卡,并返回到选项卡1之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个选项卡控件有两个(2)选项卡。该选项卡1在做一个图片框绘图(图片框是可选的,我可以直接绘制到标签),使用图形Addline。第二个标签打开网络浏览器。一切工作正常。我可以使图形中的第一个选项卡,但是当我切换到第二个选项卡,并返回到第一个选项卡,绘图消失,如果我回到标签2我可以看到我正在看的网页浏览器。我需要保持在图中的标签1,所以当我回到它,我可以看到它。下面是我使用的标签1绘制代码:

I have a Tab Control with two (2) Tabs. The Tab 1 does a drawing in a picture box (the picture box is optional, I can draw directly to the tab) using Graphics Addline. The second tab opens a web browser. Everything is working fine. I can make the drawing in the first tab but when I switch to the second tab and return to the first tab, the drawing disappear and if I return to tab 2 I can see what I was watching in the web browser. I need to kept the drawing in the tab 1 so when I return to it I can see it. Here is the code I'm using to draw in the tab 1:

私人无效DataLoaded(参考字符串strFileName)// strFileName有数据需要绘图。
{

private void DataLoaded(ref string strFileName) //strFileName has the data need for the drawing.{

图形G = this.pictureBox1.CreateGraphics();

Graphics g = this.pictureBox1.CreateGraphics();

笔黑色=新笔(Color.Black,5);

Pen black = new Pen(Color.Black, 5);

笔绿色=新朋(Color.Green,5);

Pen green = new Pen(Color.Green, 5);

列表xpoints =新名单();

List xpoints = new List();

列表ypoints中=新名单();

List ypoints = new List();

g.TranslateTransform(350,350);

g.TranslateTransform(350, 350);

g.DrawLine(绿色,新点(Convert.ToInt32(X1),Convert.ToInt32(Y1)),新点(Convert.ToInt32(X2),Convert.ToInt32( Y2)));

g.DrawLine(green, new Point(Convert.ToInt32(X1), Convert.ToInt32(Y1)), new Point(Convert.ToInt32(X2), Convert.ToInt32(Y2)));

的for(int i = 2; I< xpoints.Count();我++){

for (int i = 2; i < xpoints.Count(); i++){

            g.DrawLine(black, new Point(Convert.ToInt32(X1), Convert.ToInt32(Y1)), new Point(Convert.ToInt32(X2), Convert.ToInt32(Y2)));

            X1 = X2;
            Y1 = Y2;

            X2 = xpoints[i];
            Y2 = ypoints[i];

        }// end of for



结束

}

}

我甚至试图做使用painteventarg,但其不工作的绘图。它帮助我一点,因为当我变回选项卡1和移动鼠标在它再次提请线的标签。谁能帮我这个?我甚至用this.picturebox1.Invalidate(),但没有试过。就像我说的,我需要的是:保留在选项卡1绘图切换到选项卡,所以当我回到标签1线条后出现。在此先感谢您的帮助!

I even tried to do the drawing using the painteventarg but its not working at all. It helped me a bit because when I change back to the tab 1 and move the mouse over the tab it draws again the lines. Can anyone help me with this?? I even tried using this.picturebox1.Invalidate() but nothing. Like I said, what I need is: Preserve the drawing in tab 1 after switching to tab 2 so when I returned to tab 1 the lines are there. Thanks in advance for the help!!!.

推荐答案

它做的,我只是用位图绘制到它和集与位图PictureBox的图片

Its done, I just used a Bitmap to draw to it and the set the picturebox image with the bitmap.

下面是我使用的代码:

位图图像=新位图( pictureBox1.Width,pictureBox1.Height);
图形G = Graphics.FromImage(图像);

Bitmap image = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(image);

//在所有提取数据并做抽奖所需的代码之间

// In between all the code required for extracting the data and do the draw.

pictureBox1.Image =图像;

pictureBox1.Image = image;

感谢反正谁看见了我的问题,并试图回答这个问题。

Thanks anyway to whoever saw my question and try to answer it.

这篇关于如何保持在一个标签控件一个图片的图形描绘切换到选项卡,并返回到选项卡1之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:03