CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    MSChart - Grid Lines

    Anyone know how to get rid of the grid lines of a simple 2Dline chart?
    Below is a simple example I am trying to use but need to get rid of the grid lines. The example works just fine for what I need.
    '
    SImply add a MSCHART to a form, add a Command button and paste the code.
    Code:
    Private Sub Command1_Click()
        Dim arrPriceQuantity(1 To 5, 1 To 2)
        Dim i As Integer
        ' create some values
        For i = 1 To 5
           arrPriceQuantity(i, 1) = "Label " & i    ' Horizontal Labels
           arrPriceQuantity(i, 2) = RandomNumber(50, -10)         ' Data
        Next i
        
        MSChart1.chartType = VtChChartType2dLine
        MSChart1.ChartData = arrPriceQuantity
        
        With MSChart1.Plot.Axis(VtChAxisIdY).ValueScale
            .Auto = False
            .Minimum = -10
            .Maximum = 50
        End With
    
    End Sub
    '
    Public Function RandomNumber(T As Long, B As Long)
    Randomize   ' Initialize random-number generator.
    
    RandomNumber = Int((T * Rnd) + B)   ' Generate random value 
    Debug.Print RandomNumber
    End Function

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    Right click on the control in design time and select properties. Select the axis grid tab. For the x-axis, y-axis and second y-axis set the major gridlines style to null.

  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210
    JVBD02,

    Thanks that was it.
    Do you know of a way to set this at runtime?

  4. #4
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    Having had a quick look at the properties, I see none that would allow for what you want at runtime. However, there got to be some way of doing it - anyone else...?

  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210
    Don't need it right now but was interested for setting up a sample program that would do everything probmatically instead of having to write instructions or comments in the sample.
    '
    Thanks again

    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured