From df8a4d7596644e81b7ed1a59b1edfcf76c726471 Mon Sep 17 00:00:00 2001 From: KB Bot Date: Tue, 24 Jun 2025 14:36:21 +0000 Subject: [PATCH 1/3] Added new kb article detect-datapoint-click-radchartview-winforms --- ...t-datapoint-click-radchartview-winforms.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 knowledge-base/detect-datapoint-click-radchartview-winforms.md diff --git a/knowledge-base/detect-datapoint-click-radchartview-winforms.md b/knowledge-base/detect-datapoint-click-radchartview-winforms.md new file mode 100644 index 000000000..d25601599 --- /dev/null +++ b/knowledge-base/detect-datapoint-click-radchartview-winforms.md @@ -0,0 +1,80 @@ +--- +title: Identifying DataPoint of RadBarSeries on Click in RadChartView +description: Learn how to detect the underlying datapoint of a RadBarSeries when clicking on a specific bar in RadChartView. +type: how-to +page_title: How to Detect DataPoint on Click in RadChartView for WinForms +meta_title: How to Detect DataPoint on Click in RadChartView for WinForms +slug: detect-datapoint-click-radchartview-winforms +tags: radchartview, winforms, radbarseries, datapoint, mouseclick, hit-test +res_type: kb +ticketid: 1691155 +--- + +## Environment + + + + + + + + + + + + +
Product +RadChartView for WinForms +
Version +2025.2.520 +
+ +## Description + +I want to identify the datapoint of a RadBarSeries in RadChartView when clicking on a specific bar. I attempted using `LayoutSlots` and the `Contains` method, but the results were unreliable. + +This knowledge base article also answers the following questions: +- How to get the clicked bar datapoint in RadChartView? +- How to use HitTest to detect datapoints in RadBarSeries? +- How to handle MouseClick events for RadChartView in WinForms? + +## Solution + +To achieve this, handle the `MouseClick` event of RadChartView and use the `HitTest` method to detect the datapoint associated with the clicked bar. Follow these steps: + +1. Attach the `MouseClick` event to the RadChartView instance. +2. Inside the event handler, loop through the series in RadChartView. +3. Use `HitTest` to check if the click location corresponds to a datapoint in the RadBarSeries. +4. Retrieve and use the datapoint details as needed. + +Here is the code example: + +```csharp +this.radChartView1.MouseClick += RadChartView1_MouseClick; + +private void RadChartView1_MouseClick(object sender, MouseEventArgs e) +{ + foreach (var s in this.radChartView1.Series) + { + Telerik.WinControls.UI.BarSeries barSeries = s as Telerik.WinControls.UI.BarSeries; + if (barSeries != null) + { + DataPoint dp = barSeries.HitTest(e.Location.X, e.Location.Y); + if (dp != null) + { + Console.WriteLine(dp.Label); // Outputs the datapoint label + } + } + } +} +``` + +### Key Points: +- Replace `dp.Label` with other properties as needed to extract specific datapoint information. +- Ensure that the `MouseClick` event is appropriately attached to the RadChartView instance. + +## See Also + +- [RadChartView Documentation](https://docs.telerik.com/devtools/winforms/controls/chartview/overview) +- [HitTest Method Reference](https://docs.telerik.com/devtools/winforms/api/telerik.wincontrols.ui.barseries#hittest) +- [MouseClick Event Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.mouseclick) From c161a28587abc94592dc3d40550ad8ef6eddf6f0 Mon Sep 17 00:00:00 2001 From: Nadya Todorova <48494959+nade7o@users.noreply.github.com> Date: Tue, 24 Jun 2025 17:43:06 +0300 Subject: [PATCH 2/3] Update detect-datapoint-click-radchartview-winforms.md --- ...t-datapoint-click-radchartview-winforms.md | 48 ++++--------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/knowledge-base/detect-datapoint-click-radchartview-winforms.md b/knowledge-base/detect-datapoint-click-radchartview-winforms.md index d25601599..f273ccb90 100644 --- a/knowledge-base/detect-datapoint-click-radchartview-winforms.md +++ b/knowledge-base/detect-datapoint-click-radchartview-winforms.md @@ -1,10 +1,10 @@ --- -title: Identifying DataPoint of RadBarSeries on Click in RadChartView +title: How to detect DataPoint of RadBarSeries on Click in RadChartView description: Learn how to detect the underlying datapoint of a RadBarSeries when clicking on a specific bar in RadChartView. type: how-to page_title: How to Detect DataPoint on Click in RadChartView for WinForms meta_title: How to Detect DataPoint on Click in RadChartView for WinForms -slug: detect-datapoint-click-radchartview-winforms +slug: chartview-get-datapoint-mouse-click tags: radchartview, winforms, radbarseries, datapoint, mouseclick, hit-test res_type: kb ticketid: 1691155 @@ -12,44 +12,20 @@ ticketid: 1691155 ## Environment - - - - - - - - - - - -
Product -RadChartView for WinForms -
Version -2025.2.520 -
+|Product Version|Product|Author| +|----|----|----| +|2025.2.520|RadChartView for WinForms|[Nadya Todorova](https://www.telerik.com/blogs/author/nadya-karaivanova)| ## Description -I want to identify the datapoint of a RadBarSeries in RadChartView when clicking on a specific bar. I attempted using `LayoutSlots` and the `Contains` method, but the results were unreliable. - -This knowledge base article also answers the following questions: -- How to get the clicked bar datapoint in RadChartView? -- How to use HitTest to detect datapoints in RadBarSeries? -- How to handle MouseClick events for RadChartView in WinForms? +This article shows how to identify a datapoint of a RadBarSeries in RadChartView when clicking on a specific bar. ## Solution -To achieve this, handle the `MouseClick` event of RadChartView and use the `HitTest` method to detect the datapoint associated with the clicked bar. Follow these steps: - -1. Attach the `MouseClick` event to the RadChartView instance. -2. Inside the event handler, loop through the series in RadChartView. -3. Use `HitTest` to check if the click location corresponds to a datapoint in the RadBarSeries. -4. Retrieve and use the datapoint details as needed. - +To achieve this, handle the `MouseClick` event of RadChartView and use the `HitTest` method to detect the datapoint associated with the clicked bar. Here is the code example: -```csharp +````C# this.radChartView1.MouseClick += RadChartView1_MouseClick; private void RadChartView1_MouseClick(object sender, MouseEventArgs e) @@ -67,14 +43,10 @@ private void RadChartView1_MouseClick(object sender, MouseEventArgs e) } } } -``` -### Key Points: -- Replace `dp.Label` with other properties as needed to extract specific datapoint information. -- Ensure that the `MouseClick` event is appropriately attached to the RadChartView instance. +``` ## See Also - [RadChartView Documentation](https://docs.telerik.com/devtools/winforms/controls/chartview/overview) -- [HitTest Method Reference](https://docs.telerik.com/devtools/winforms/api/telerik.wincontrols.ui.barseries#hittest) -- [MouseClick Event Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.mouseclick) +- [BarSeries](https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/bar) From 51c80dcec43becebebf838811ffbca1d9d4a28b1 Mon Sep 17 00:00:00 2001 From: Dinko Krastev Date: Thu, 3 Jul 2025 16:57:10 +0300 Subject: [PATCH 3/3] Update detect-datapoint-click-radchartview-winforms.md --- .../detect-datapoint-click-radchartview-winforms.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/knowledge-base/detect-datapoint-click-radchartview-winforms.md b/knowledge-base/detect-datapoint-click-radchartview-winforms.md index f273ccb90..947f6a2de 100644 --- a/knowledge-base/detect-datapoint-click-radchartview-winforms.md +++ b/knowledge-base/detect-datapoint-click-radchartview-winforms.md @@ -1,11 +1,11 @@ --- -title: How to detect DataPoint of RadBarSeries on Click in RadChartView -description: Learn how to detect the underlying datapoint of a RadBarSeries when clicking on a specific bar in RadChartView. +title: How to detect DataPoint of RadBarSeries on Mouse Click in RadChartView +description: Learn how to detect the underlying datapoint of a BarSeries when clicking on a specific bar in RadChartView. type: how-to page_title: How to Detect DataPoint on Click in RadChartView for WinForms meta_title: How to Detect DataPoint on Click in RadChartView for WinForms slug: chartview-get-datapoint-mouse-click -tags: radchartview, winforms, radbarseries, datapoint, mouseclick, hit-test +tags: chartview, winforms, barseries, datapoint, mouseclick, hit-test res_type: kb ticketid: 1691155 --- @@ -26,6 +26,7 @@ To achieve this, handle the `MouseClick` event of RadChartView and use the `HitT Here is the code example: ````C# + this.radChartView1.MouseClick += RadChartView1_MouseClick; private void RadChartView1_MouseClick(object sender, MouseEventArgs e) @@ -44,9 +45,9 @@ private void RadChartView1_MouseClick(object sender, MouseEventArgs e) } } -``` +```` ## See Also -- [RadChartView Documentation](https://docs.telerik.com/devtools/winforms/controls/chartview/overview) -- [BarSeries](https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/bar) +* [RadChartView Documentation](https://docs.telerik.com/devtools/winforms/controls/chartview/overview) +* [BarSeries](https://docs.telerik.com/devtools/winforms/controls/chartview/series-types/bar)