Skip to content

Commit 88f9871

Browse files
authored
Merge pull request #740 from telerik/new-kb-detect-datapoint-click-radchartview-winforms-7ab7e5638af94b11ba9a6e434ddb30ad
Added new kb article detect-datapoint-click-radchartview-winforms
2 parents a044c8a + 51c80dc commit 88f9871

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: How to detect DataPoint of RadBarSeries on Mouse Click in RadChartView
3+
description: Learn how to detect the underlying datapoint of a BarSeries when clicking on a specific bar in RadChartView.
4+
type: how-to
5+
page_title: How to Detect DataPoint on Click in RadChartView for WinForms
6+
meta_title: How to Detect DataPoint on Click in RadChartView for WinForms
7+
slug: chartview-get-datapoint-mouse-click
8+
tags: chartview, winforms, barseries, datapoint, mouseclick, hit-test
9+
res_type: kb
10+
ticketid: 1691155
11+
---
12+
13+
## Environment
14+
15+
|Product Version|Product|Author|
16+
|----|----|----|
17+
|2025.2.520|RadChartView for WinForms|[Nadya Todorova](https://www.telerik.com/blogs/author/nadya-karaivanova)|
18+
19+
## Description
20+
21+
This article shows how to identify a datapoint of a RadBarSeries in RadChartView when clicking on a specific bar.
22+
23+
## Solution
24+
25+
To achieve this, handle the `MouseClick` event of RadChartView and use the `HitTest` method to detect the datapoint associated with the clicked bar.
26+
Here is the code example:
27+
28+
````C#
29+
30+
this.radChartView1.MouseClick += RadChartView1_MouseClick;
31+
32+
private void RadChartView1_MouseClick(object sender, MouseEventArgs e)
33+
{
34+
foreach (var s in this.radChartView1.Series)
35+
{
36+
Telerik.WinControls.UI.BarSeries barSeries = s as Telerik.WinControls.UI.BarSeries;
37+
if (barSeries != null)
38+
{
39+
DataPoint dp = barSeries.HitTest(e.Location.X, e.Location.Y);
40+
if (dp != null)
41+
{
42+
Console.WriteLine(dp.Label); // Outputs the datapoint label
43+
}
44+
}
45+
}
46+
}
47+
48+
````
49+
50+
## See Also
51+
52+
* [RadChartView Documentation](https://docs.telerik.com/devtools/winforms/controls/chartview/overview)
53+
* [BarSeries](https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/bar)

0 commit comments

Comments
 (0)