Results 1 to 10 of 10

Thread: [RESOLVED] using flexgrid to make a graph

  1. #1

    Thread Starter
    Member fishbyname's Avatar
    Join Date
    Feb 2006
    Location
    Bournemouth / Loughborough
    Posts
    43

    Resolved [RESOLVED] using flexgrid to make a graph

    is there a way to use the data stored in a flexgrid?

    i some simple data inserted into the flexgrid and it would be great if i could produce a graph from it, and even better than that would be if i could save the graph

    many thanks

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: using flexgrid to make a graph

    You can use a Chart control or a Picturebox, then just get your values in a loop while you draw them.

  3. #3

    Thread Starter
    Member fishbyname's Avatar
    Join Date
    Feb 2006
    Location
    Bournemouth / Loughborough
    Posts
    43

    Re: using flexgrid to make a graph

    how do you get the data from the flexgrid into the chart though

    do you link put a link in somewhere?

    or is there an insert statement that takes each cell and inserts their value into a data table?

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: using flexgrid to make a graph

    Ok, example. Add a Flexgrid (MsFlexgrid1) and a Picturebox (Picture1) to your Form, and paste this code:
    VB Code:
    1. Private Sub Form_Load()
    2.     'Configure flexgrid
    3.     With MSFlexGrid1
    4.         .Rows = 10
    5.         .Cols = 3
    6.     End With
    7.     'Configure Picturebox
    8.     With Picture1
    9.         .AutoRedraw = True
    10.         .ScaleMode = vbPixels
    11.         .BackColor = vbYellow
    12.         .ScaleLeft = 0
    13.         .ScaleWidth = 9
    14.         .ScaleTop = 81
    15.         .ScaleHeight = -81
    16.         .DrawWidth = 2
    17.     End With
    18.     LoadValues
    19.     DrawLine
    20.     Me.Show
    21.     SaveGraph "C:\MyGraph.bmp"
    22. End Sub
    23.  
    24. Private Sub LoadValues()
    25. Dim i As Long
    26.     With MSFlexGrid1
    27.         .TextMatrix(0, 1) = "X"
    28.         .TextMatrix(0, 2) = "Y"
    29.         For i = 1 To MSFlexGrid1.Rows - 1
    30.             .TextMatrix(i, 1) = i
    31.             .TextMatrix(i, 2) = i ^ 2
    32.         Next
    33.     End With
    34. End Sub
    35.  
    36. Private Sub DrawLine()
    37. Dim i As Long, x As Long, y As Long, oldx As Long, oldy As Long
    38.     oldx = 0
    39.     oldy = 0
    40.     With MSFlexGrid1
    41.         For i = 1 To MSFlexGrid1.Rows - 1
    42.             x = CLng(.TextMatrix(i, 1))
    43.             y = CLng(.TextMatrix(i, 2))
    44.             Picture1.Line (oldx, oldy)-(x, y), vbRed
    45.             oldx = x
    46.             oldy = y
    47.         Next
    48.     End With
    49. End Sub
    50.  
    51. Private Sub SaveGraph(pPath As String)
    52.     SavePicture Picture1.Image, pPath
    53.     MsgBox "Image saved in " & pPath, vbInformation + vbOKOnly, "Done"
    54. End Sub
    Last edited by jcis; Mar 30th, 2006 at 01:30 PM.

  5. #5

    Thread Starter
    Member fishbyname's Avatar
    Join Date
    Feb 2006
    Location
    Bournemouth / Loughborough
    Posts
    43

    Re: using flexgrid to make a graph

    thanks jcis, that works great

    don't suppose you have used mschart before, i'd like to use something which i can customise quite a lot

  6. #6
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: using flexgrid to make a graph

    I never used this control but it looks very nice and I heard it's easy to use, give it a try: RMChart
    See the examples in Chart examples, you can also create one online in Server example

  7. #7

    Thread Starter
    Member fishbyname's Avatar
    Join Date
    Feb 2006
    Location
    Bournemouth / Loughborough
    Posts
    43

    Re: using flexgrid to make a graph

    it does look good, had a play about with it, can't find a way to link it to my flexgrid though

    has anyone else used this control with a flexgrid?

  8. #8
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: using flexgrid to make a graph

    Did you ever try RMChart?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  9. #9
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: using flexgrid to make a graph

    Quote Originally Posted by fishbyname
    it does look good, had a play about with it, can't find a way to link it to my flexgrid though
    has anyone else used this control with a flexgrid?
    Send a PM to Lintz, I think he used this control.

  10. #10

    Thread Starter
    Member fishbyname's Avatar
    Join Date
    Feb 2006
    Location
    Bournemouth / Loughborough
    Posts
    43

    Re: using flexgrid to make a graph

    cheers for the tip off about lintz, works a treat now

    thanks

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