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 8230869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:16:43+00:00 2026-06-07T17:16:43+00:00

Hello i am trying to add a click event to chart points but i

  • 0

Hello i am trying to add a click event to chart points but i am getting the following Error when i click the chart “Object reference not set to an instance of an object”

here is my code

Private Sub Chart1_Click(sender As Object, e As System.EventArgs) Handles Chart1.Click
    Try
        Dim pointindex As Integer
        If result.ChartElementType = ChartElementType.DataPoint Then
            pointindex = result.PointIndex
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

Private Sub Form1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    result = Chart1.HitTest(e.X, e.Y)
End Sub
  • 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-06-07T17:16:45+00:00Added an answer on June 7, 2026 at 5:16 pm

    If the mouse cursor is above a control only the control will receive events but not the form (for workarounds see e.g. this question: Winforms : Intercepting Mouse Event on Main Form first, not on Controls).

    So Form1_MouseDown will not fire and result will still be Nothing in Chart1_Click.

    A workaround could look like this:

    Private Sub Chart1_Click(sender As Object, e As System.EventArgs) Handles Chart1.Click
        Try
            Dim pointindex As Integer
            Dim result As HitTestResult
            result = Chart1.HitTest(Cursor.Position.X, Cursor.Position.Y)
            If result.ChartElementType = ChartElementType.DataPoint Then
                pointindex = result.PointIndex
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello i am trying a sqlite database tutorial to build, but its not working
Hello I'm trying to dynamically generate some inputs for my form, but it's not
I'm trying to write a cross-browser event addition method but it's not working in
Hello im trying to echo only the 50 letters, but something in my code
Hello I was trying to remove objects from object array that I have and
Hello I am trying to create a custom expandable listview, but the documentation on
Hello i was trying to modify an object form the values of another object
Hello there I am trying to add a Library to an Android application. I
I am just trying to add a Hello World or a program that draw
Using Titanium Appcelerator I am trying to dynamically create elements and add event listeners

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.