CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2012
    Posts
    7

    Unhappy 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,

  2. #2
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    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.......

  3. #3
    Join Date
    Feb 2012
    Posts
    7

    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

  4. #4
    Join Date
    Feb 2012
    Posts
    7

    Re: graph is vanished in tabpage

    the timer was refereshed for every 1 second

  5. #5
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    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.......

  6. #6
    Join Date
    Feb 2012
    Posts
    7

    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
  •  





Click Here to Expand Forum to Full Width

Featured