Clearing Drawline Handles after Delete

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Clearing Drawline Handles after Delete

Post by lilo » Sun Jul 01, 2012 3:43 am

I am having trouble clearing drawline handles after deleting a selected line.

For example:

DrawLine1.Lines.Remove(DrawLine1.Lines.Item(NumLine))
Tchart1.Redraw

This will delete the line but leaves the drawline handles on the canvas, if the line has been selected.

Is there another way to clear the line and handles?

Can I clear all selections before deleting the line?

Drawline.DeleteSelected() is not suitable for my purpose, as the line I want to delete is not always the selected line.

Is this a bug?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Clearing Drawline Handles after Delete

Post by Sandra » Thu Jul 05, 2012 3:26 pm

Hello lilo,

I inform you I have added your problem with Remove DrawLine, in the bug list report with number[TF02016242]. We will try to fix it upcoming maintenance releases. On the other hand, I think you can use DeleteSelected() as a workaround as do in next lines of code:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line Series1;
        Steema.TeeChart.Tools.DrawLine drawLine1;
        private void InitializeChart()
        { //InitializeChart
            tChart1.Aspect.View3D = false;
            //Series
            Series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            this.Series1.FillSampleValues();
            //Tool
            drawLine1 = new DrawLine(tChart1.Chart);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean [] deletLine = new Boolean[drawLine1.Lines.Count];
            for (int i = 0; i < drawLine1.Lines.Count; i++)
            {
                if (i % 3 == 0)
                {

                    deletLine[i] = true;
                }
                else
                {
                    deletLine[i] = false;
                }
            }
            //Tool
            Steema.TeeChart.Tools.DrawLineItem drawlineItem1 = drawLine1.Lines[0];
            //Save DrawLineItem;
            drawLine1.Selected = drawlineItem1;
            for (int i = 0; i < drawLine1.Lines.Count; i++ )
            {
                Steema.TeeChart.Tools.DrawLineItem I = drawLine1.Lines[i];
                if (deletLine[i])
                {
                    if (I != drawlineItem1)
                    {
                        drawLine1.Selected = I;
                        drawLine1.DeleteSelected();
                    }
                    else { drawLine1.DeleteSelected(); }
                }
            }
        }
Can you tell us if previous code works as you expected?
Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Re: Clearing Drawline Handles after Delete

Post by lilo » Fri Jul 06, 2012 6:31 am

Thanks Sandra,

Your workaround contains some clues how to fix the problem. Now working fine.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Clearing Drawline Handles after Delete

Post by Sandra » Fri Jul 06, 2012 7:16 am

Hello lilo,

I am glad that my solution helps you.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Clearing Drawline Handles after Delete

Post by Sandra » Wed Sep 19, 2012 10:50 am

Hello lilo,

I inform you that the bug number [TF02016242] isn't a bug, because you can solve the problem with the handles, setting the DrawLine.Selected to null as do in next code:

Code: Select all

    public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.Line Series1;
        Steema.TeeChart.Tools.DrawLine drawLine1;
        private void InitializeChart()
        { //InitializeChart
            tChart1.Aspect.View3D = false;
            //Series
            Series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            this.Series1.FillSampleValues();
            //Tool
            drawLine1 = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
        }
        private void button1_Click(object sender, EventArgs e)
        {

            if (drawLine1.Lines.Count != 0)
            {
                if (drawLine1.Lines.Count > 1)
                {
                    Steema.TeeChart.Tools.DrawLineItem I = drawLine1.Selected;
                    drawLine1.Lines.Remove(I);
                    drawLine1.Selected = null;
                    
                }
                else
                {
                    drawLine1.Lines.Remove(drawLine1.Lines[0]);

                }
            }
        }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply