none
Error with dialog

    Question

  • Hi,

    I'm trying to use one of the samples of the Microsoft Chart for Windows Forms Samples Enviroment, but I can't reproduce one of them. The code is as follows:

    Imports System.Windows.Forms.DataVisualization.Charting
    ...
    
    ' Mouse Down Event
    Private Sub Chart1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseDown
        ' Call Hit Test Method
        Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)
    
        If result.ChartElementType = ChartElementType.DataPoint Then
           
        'Create Dialog
        Dim dlg As New Dialog()
           
        'Initialize members
        dlg.ChartRef = Chart1
        dlg.pointIndex = result.PointIndex
           
        ' Show dialog
        dlg.Show()
    
        Else
        If result.ChartElementType <> ChartElementType.Nothing Then
            Dim elementType As String = result.ChartElementType.ToString()
            MessageBox.Show(Me, "Selected Element is: " + elementType)
        End If
        End If
    End Sub 'Chart1_MouseDown
     
    ' Mouse Move Event
    Private Sub Chart1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Chart1.MouseMove
        ' Call Hit Test Method
        Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)
    
        ' If a Data Point or a Legend item is selected.
        If result.ChartElementType = ChartElementType.DataPoint Or result.ChartElementType = ChartElementType.LegendItem Then
            ' Set cursor type 
            Me.Cursor = Cursors.Hand
        Else
            If result.ChartElementType <> ChartElementType.Nothing And result.ChartElementType <> ChartElementType.PlottingArea Then
                ' Set cursor type 
                Me.Cursor = Cursors.Hand
            Else
                ' Set default cursor
                Me.Cursor = Cursors.Default
            End If
        End If
    End Sub 'Chart1_MouseMove 
    

    The error is in the Dim dlg As New Dialog() as it tells me that the type "Dialog" is not defined. Is there any import I'm missing? Have looked around forums and documentation, but haven't found something that helps me.

    Tuesday, April 25, 2017 3:21 PM

All replies

  • The error is in the Dim dlg As New Dialog() as it tells me that the type "Dialog" is not defined. Is there any import I'm missing? Have looked around forums and documentation, but haven't found something that helps me.

    Is Dialog a class that is defined in an earlier example?  It isn't a standard component in .Net (the properties ChartRef and pointIndex appear to be unique to that class).   It appears to be a form that has been set up as a standard container for a chart.


    • Edited by AcamarMVP Wednesday, April 26, 2017 9:27 PM fmt
    • Proposed as answer by Frank L. Smith Wednesday, April 26, 2017 10:12 PM
    Wednesday, April 26, 2017 9:27 PM