无法在HorizBar中触发Click事件

时间:2017-04-14 03:27:06

标签: winforms teechart

我正在使用TeeChart for WinForm版本:4.1.2016.5122。但是当鼠标移动到系列并单击它们时,不会触发相关事件。 有没有人遇到过这个问题?

for (int i = 0; i < 4; i++)
{
    HorizBar bar = new HorizBar(m_barChart.Chart);

    bar.MultiBar = MultiBars.Stacked;
    bar.Cursor = Cursors.Hand;
    bar.BarHeightPercent = 100;
    bar.CustomBarWidth = 20;

    //Event registered below will not be fired up
    bar.Click += Bar_Click1;

    bar.Depth = 50;
    bar.DepthPercent = 50;
    bar.Marks.Visible = false;
    bar.Color = Color.Blue;
    bar.Add(i, 0);

    bar.Title = string.Format(" {0} {1}", i, i);
}

//Event registered below is not fired up
m_barChart.ClickSeries += M_barChart_ClickSeries;

1 个答案:

答案 0 :(得分:0)

使用TeeChart.Net v4.1.2016.5122下面的代码,ClickSeries会毫无问题地触发。

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            for (int i = 0; i < 4; i++)
            {
                HorizBar bar = new HorizBar(tChart1.Chart);

                bar.MultiBar = MultiBars.Stacked;
                bar.Cursor = Cursors.Hand;
                bar.BarHeightPercent = 100;
                bar.CustomBarWidth = 20;

                bar.Depth = 50;
                bar.DepthPercent = 50;
                bar.Marks.Visible = false;
                bar.Color = Color.Blue;
                bar.Add(i, 0);

                bar.Title = string.Format(" {0} {1}", i, i);
            }

            tChart1.ClickSeries += TChart1_ClickSeries;

        }


        private void TChart1_ClickSeries(object sender, Series s, int valueIndex, MouseEventArgs e)
        {
                this.Text = s.Title;
        }

您是否可以再次检查代码并确认我们是否适用于您?

提前致谢

最好的问候