Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:53:20+00:00 2026-05-24T02:53:20+00:00

I have done like this for creating click event handler for one part of

  • 0

I have done like this for creating click event handler for one part of the chart using mschart control, the chart is like this enter image description here

and the code like this

private void targetChartmouse_Click(object sender, MouseEventArgs e)
{ 
  try
  {
    var pos = e.Location;
    var results = kpiChartControl.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
    foreach (var result in results)
    {
      if (result.ChartElementType == ChartElementType.DataPoint)
      { 
        //do something....
      }
    }        
  }
}

It’s working fine when we click on the chart (in every section of chart), but I want to do something only when we click on the live(green), not on every part. Is it possible to find the region of live(green)

Is it possible using c#?

I am doing winforms application

Modified Code

     public void targetChartmouse_Click(object sender, MouseEventArgs e)
   {
  Series statusseries = new Series();
  Series liveseries = null;
  Title title;
  string area;

  //Series totalserries;
  try
  {
    var pos = e.Location;
    var results = kpiChartControl.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
    foreach (var result in results)
    {
      if (result.ChartElementType == ChartElementType.DataPoint)
      {

          DataTable accepts = null;
          accepts = KPIData.livemembersmembershiptype(mf);

          DataTable membershiptypes = null;
          membershiptypes = KPIData.MembershipTotals(dtStartDate.Value, dtEndDate.Value, mf);

          area = "subchart";
          kpiChartControl.ChartAreas.Add(area);
          statusseries = kpiChartControl.Series.Add(area);
          statusseries.ChartArea = area;

          title = kpiChartControl.Titles.Add("Live Status  members  By MemberShip Type");
          title.DockedToChartArea = area;
          title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
          title.Alignment = ContentAlignment.TopLeft;
          kpiChartControl.Titles.Add("").DockedToChartArea = area;
          kpiChartControl.Titles.Add("Live status membership types").DockedToChartArea = area;


          area = "";
          kpiChartControl.Titles.Add("").DockedToChartArea = area;




          foreach (Title titles in kpiChartControl.Titles)
          {
            titles.IsDockedInsideChartArea = false;
          }


          foreach (ChartArea chartArea in kpiChartControl.ChartAreas)
          {
            chartArea.Area3DStyle.Enable3D = true;
            chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;
            //chartArea.AxisX.LabelStyle.IsEndLabelVisible = !overview;
          }

          if (area == "subchart")
          {
            foreach (Series chartSeries in kpiChartControl.Series)
            {
              chartSeries.ChartType = SeriesChartType.StackedColumn;
              chartSeries["ColumnDrawingStyle"] = "SoftEdge";
              chartSeries["LabelStyle"] = "Top";
              chartSeries.IsValueShownAsLabel = true;
              chartSeries.BackGradientStyle = GradientStyle.DiagonalLeft;
            }
          }
          else if (area == "subchart")
          {
            foreach (Series chartSeries in kpiChartControl.Series)
            {
              chartSeries.ChartType = SeriesChartType.Pie;

              //chartSeries["PieLabelStyle"] = "Outside";
              chartSeries["PieLabelStyle"] = "Inside";
              chartSeries["DoughnutRadius"] = "30";
              chartSeries["PieDrawingStyle"] = "SoftEdge";

              chartSeries.BackGradientStyle = GradientStyle.DiagonalLeft;

            }

          }

          foreach (Legend legend in kpiChartControl.Legends)
          {
            legend.Enabled = false;
          }

          if (membershiptypes == null)
          {
            statusseries.Points.Clear();
            statusseries.Points.AddXY("no status", 0);

          }
          if (accepts == null)
          {
            liveseries.Points.Clear();
            liveseries.Points.AddXY("no live", 0);

          }
          kpiChartControl.Series["subchart"].Points.DataBindXY(accepts.Rows, "mshipname", accepts.Rows, "count");
          kpiChartControl.Series[0].Points.DataBindXY(membershiptypes.Rows, "Status", membershiptypes.Rows, "Value");

        }

        foreach (Series chartSeries in kpiChartControl.Series)
        {
          foreach (DataPoint point in chartSeries.Points)
          {

            switch (point.AxisLabel)
            {
              case "Silver membership": point.Color = Color.Green; break;
              case "Gold Membership": point.Color = Color.Blue; break;
              //case "Refused": point.Color = Color.Red; break;
              case "Weekend Peak": point.Color = Color.Cyan; break;
              case "prspect": point.Color = Color.Indigo; break;

            }
            point.Label = string.Format("{0:0}", point.YValues[0]);
          }

        }

        foreach (Series chartSeries in kpiChartControl.Series)
        {
          foreach (DataPoint point in chartSeries.Points)
          {
            switch (point.AxisLabel)
            {
              case "New": point.Color = Color.Cyan; break;
              case "Live": point.Color = Color.Green; break;
              case "Defaulter": point.Color = Color.Red; break;
              case "Cancelled": point.Color = Color.Orange; break;
              case "Completed": point.Color = Color.Blue; break;
              case "Frozen": point.Color = Color.Violet; break;
            }

            point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);
          }
        }

    }
  }
  catch
  {
  }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:53:21+00:00Added an answer on May 24, 2026 at 2:53 am

    This might work:

    try
    {
      var pos = e.Location;
      var results = kpiChartControl.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
      foreach (var result in results)
      {
        if (result.ChartElementType == ChartElementType.DataPoint)
        {
          if (result.Series.Points[result.PointIndex].AxisLabel == "Live")
          {
            Console.WriteLine("success?");
          }
        }
      }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have done something like this: <form action=validate.php method=get> Id :<input type=text name=pID/><br/><br/> Name
I am trying to create something like this as i have done it in
I have done like if user click on the Button then the Sound is
I'm creating a Yahoo! Widget and have done this before without any problems (creating
I would like to read custom setting which i have done in ServiceConfiguration.cscfg &
Most of my development life, I have done a JavaScript generated button like so:
I feel like GUID/UUID questions have been done to death here, but I can't
I have never done any Windows coding and I would like to give it
I would like to track how many surveys have been done by different departments
I've done enough Googling to know that if I have something like class SubObject

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.