-
February 26th, 2012, 03:41 AM
#1
graph is vanished in tabpage
Hi,
this is jagadeesh, iam visual studio 10 IDE and c# language for one grafical application .
for that application i used tabpages, one of that tab pages i have to draw graph in that page.it works also but while i selected another page the control goes to that page, after return to graph page the graph is vanished.but i didn't want that .any body can help abiut this problem.
thankyou,
-
February 26th, 2012, 05:32 PM
#2
Re: graph is vanished in tabpage
1) How are you drawing the graph?
2) In which part of your code are you drawing the graph?
Post some of your code here.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
February 27th, 2012, 07:05 AM
#3
Re: graph is vanished in tabpage
here iam sending my sample code which is run in timer block
this graph raises between voltage and time
Code:
private void timer1_Tick_1(object sender, EventArgs e)
{
Graphics g = this.tabLoadPage.CreateGraphics();
//System.Drawing.Drawing2D.GraphicsState graph = g.Save();
//g.Restore(graph);
if (flg == true)
{
y1 = y2;
x2 = x2 + 5; // for increse time leve
flg = false;
}
else if (flg == false)
{
x1 = x2; // here i iam taking reference point of time level
y2 = Convert.ToInt16(398 - ((dta[load_val] / 1000) * 32.25)); ; // for increse voltage level
flg = true;
}
g.DrawLine(p, x1, y1, x2, y2);
}
this code was working in tabpage1(tabloadpage).if i press next tab page ,the controll goes to that age at that time graph is vanished .this is my problem please help me
thank you,
Last edited by Cimperiali; February 27th, 2012 at 09:08 AM.
Reason: added [code][/code] tags
-
February 27th, 2012, 07:07 AM
#4
Re: graph is vanished in tabpage
the timer was refereshed for every 1 second
-
February 27th, 2012, 05:38 PM
#5
Re: graph is vanished in tabpage
You need to draw all of the lines every time in your Paint handler.
I just wrote this code, it may help you make some progress.
Code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
List<Point> _points = new List<Point>();
Random _random = new Random();
public Form1()
{
InitializeComponent();
// at least two points are required...
_points.Add(new Point(0, 0));
_points.Add(new Point(this.Width, this.Height));
timer1.Start();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawLines(Pens.Blue, _points.ToArray());
}
private void timer1_Tick(object sender, EventArgs e)
{
_points.Add(new Point(_random.Next(this.Width), _random.Next(this.Height)));
this.Invalidate();
}
}
}
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
March 12th, 2012, 11:34 PM
#6
Re: graph is vanished in tabpage
Thank you Sir, your suggestion is useful to me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|