# chart-user-interaction-chart-custom-trend-lines

> Chart that overlays custom trend lines with editable slopes and intercepts, showing dynamic trend analysis on the data series.

**Framework:** winforms  **Component:** Chart  **Variant:** user-interaction-chart-custom-trend-lines

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/winforms/chart-user-interaction-chart-custom-trend-lines.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.Chart.Windows
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/chart-user-interaction-chart-custom-trend-lines/chart.Designer.cs

```cs
namespace ClickPointDemo2
{
    public partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl();
            panel2 = new System.Windows.Forms.Panel();
            panel2.SuspendLayout();
            SuspendLayout();
            // 
            // chartControl1
            // 
            chartControl1.BackInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.White, System.Drawing.Color.White);
            chartControl1.ChartArea.BackInterior = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.Color.Transparent, System.Drawing.Color.Transparent);
            chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0);
            chartControl1.ChartArea.CursorReDraw = false;
            chartControl1.ChartInterior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.Transparent);
            // 
            // 
            // 
            chartControl1.Legend.BackInterior = new Syncfusion.Drawing.BrushInfo();
            chartControl1.Legend.Font = new System.Drawing.Font("Verdana", 10F);
            chartControl1.Legend.Location = new System.Drawing.Point(781, 81);
            chartControl1.Legend.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            chartControl1.Location = new System.Drawing.Point(142, 35);
            chartControl1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            chartControl1.Name = "chartControl1";
            chartControl1.PrimaryXAxis.LogLabelsDisplayMode = Syncfusion.Windows.Forms.Chart.LogLabelsDisplayMode.Default;
            chartControl1.PrimaryXAxis.Margin = true;
            chartControl1.PrimaryYAxis.LogLabelsDisplayMode = Syncfusion.Windows.Forms.Chart.LogLabelsDisplayMode.Default;
            chartControl1.PrimaryYAxis.Margin = true;
            chartControl1.Size = new System.Drawing.Size(917, 823);
            chartControl1.TabIndex = 0;
            chartControl1.Text = "Chart Custom Trend Lines";
            // 
            // 
            // 
            chartControl1.Title.Name = "Def_title";
            chartControl1.Title.Text = "Chart Custom Trend Lines";
            chartControl1.Titles.Add(chartControl1.Title);
            // 
            // panel2
            // 
            panel2.Controls.Add(chartControl1);
            panel2.Location = new System.Drawing.Point(0, 0);
            panel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            panel2.Name = "panel2";
            panel2.Size = new System.Drawing.Size(933, 831);
            panel2.TabIndex = 6;
            // 
            // Form1
            // 
            AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            BackColor = System.Drawing.Color.White;
            ClientSize = new System.Drawing.Size(1271, 891);
            Controls.Add(panel2);
            Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            MinimumSize = new System.Drawing.Size(667, 776);
            Name = "Form1";
            StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            Text = "Chart Custom Trend Lines";
            Load += Form1_Load;
            panel2.ResumeLayout(false);
            ResumeLayout(false);

        }

        #endregion

        private Syncfusion.Windows.Forms.Chart.ChartControl chartControl1;

        private System.Windows.Forms.Panel panel2;
    }
}

```

### src/components/chart-user-interaction-chart-custom-trend-lines/chart.cs

```cs
﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Syncfusion.Windows.Forms;
using Syncfusion.Windows.Forms.Chart;
using System.Collections;
using System.Drawing.Drawing2D;
using Syncfusion.Drawing;

namespace ClickPointDemo2
{
    public partial class Form1 : MetroForm
    {
        #region Form Constructor
        private Random rand = new Random();
        public Form1()
        {
            BorderColor = Color.FromArgb(0xFF, 0xCD, 0xCD, 0xCD);
            BorderThickness = 3;
            CaptionBarHeight = 75;
            CaptionBarColor = Color.FromArgb(0xFF, 0x1B, 0xA1, 0xE2);
            CaptionFont = new Font("Segoe UI", 22.0f);
            CaptionForeColor = Color.White;
            CaptionAlign = HorizontalAlignment.Left;
            ShowIcon = false;
            CaptionButtonColor = Color.White;
            CaptionButtonHoverColor = Color.White;
            InitializeComponent();
        }
        #endregion

        #region Form Load
        private TrendLineRenderer tlineRenderer;
        private void Form1_Load(object sender, EventArgs e)
        {
            this.tlineRenderer = new TrendLineRenderer(this.chartControl1);          
            this.InitializeChartData();

            this.chartControl1.Dock = DockStyle.Fill;
            this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
            ChartAppearance.ApplyChartStyles(this.chartControl1);
           
           
        }
        #endregion

        #region Helper Methods        
       
        #region InitializeChartData
        private void InitializeChartData()
        {
            DateTime d = DateTime.Now;
            ChartSeries series1 = new ChartSeries("Stock", ChartSeriesType.Column);
            series1.Text = series1.Name;

            this.chartControl1.Series.Add(series1);

            for (int i = 0; i < 10; i++)
            {
                if (i <= 2)
                    series1.Points.Add(i, rand.Next(25, 38));
                else if (i > 2 && i <= 3)
                    series1.Points.Add(i, rand.Next(38, 45));
                else if (i > 3 && i <= 5)
                    series1.Points.Add(i, rand.Next(42, 50));
                else if (i > 5 && i <= 6)
                    series1.Points.Add(i, rand.Next(50, 60));
                else if (i > 6 && i <= 8)
                    series1.Points.Add(i, rand.Next(58, 72));
                else
                    series1.Points.Add(i, rand.Next(62, 78));
            }

            this.chartControl1.Series[0].Style.Border.Width = 2;
            this.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
         //   this.chartControl1.PrimaryYAxis.Range = new MinMaxInfo(0, 160, 20);
            this.chartControl1.PrimaryYAxis.Format = " 0";
            chartControl1.ShowLegend = false;

            this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Double;
            this.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
            this.chartControl1.PrimaryXAxis.LabelIntersectAction = ChartLabelIntersectAction.MultipleRows;

            // Tooltip
            this.chartControl1.ShowToolTips = true;

            Trendline trendline = new Trendline();
            //Customizing the Trendline
            trendline.Name = "Linear";
            trendline.Visible = true;
            trendline.Style = DashStyle.Dash;
            trendline.Width = 2f;
            trendline.Color = Color.Black;
            trendline.Type = TrendlineType.Linear;
            //Adding Trendline to the series
            this.chartControl1.Series[0].Trendlines.Add(trendline);
        }
        #endregion
        #endregion
    }

}

```
