|
-
Mar 30th, 2006, 10:32 AM
#1
Thread Starter
Member
[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
-
Mar 30th, 2006, 10:39 AM
#2
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.
-
Mar 30th, 2006, 10:47 AM
#3
Thread Starter
Member
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?
-
Mar 30th, 2006, 01:27 PM
#4
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:
Private Sub Form_Load()
'Configure flexgrid
With MSFlexGrid1
.Rows = 10
.Cols = 3
End With
'Configure Picturebox
With Picture1
.AutoRedraw = True
.ScaleMode = vbPixels
.BackColor = vbYellow
.ScaleLeft = 0
.ScaleWidth = 9
.ScaleTop = 81
.ScaleHeight = -81
.DrawWidth = 2
End With
LoadValues
DrawLine
Me.Show
SaveGraph "C:\MyGraph.bmp"
End Sub
Private Sub LoadValues()
Dim i As Long
With MSFlexGrid1
.TextMatrix(0, 1) = "X"
.TextMatrix(0, 2) = "Y"
For i = 1 To MSFlexGrid1.Rows - 1
.TextMatrix(i, 1) = i
.TextMatrix(i, 2) = i ^ 2
Next
End With
End Sub
Private Sub DrawLine()
Dim i As Long, x As Long, y As Long, oldx As Long, oldy As Long
oldx = 0
oldy = 0
With MSFlexGrid1
For i = 1 To MSFlexGrid1.Rows - 1
x = CLng(.TextMatrix(i, 1))
y = CLng(.TextMatrix(i, 2))
Picture1.Line (oldx, oldy)-(x, y), vbRed
oldx = x
oldy = y
Next
End With
End Sub
Private Sub SaveGraph(pPath As String)
SavePicture Picture1.Image, pPath
MsgBox "Image saved in " & pPath, vbInformation + vbOKOnly, "Done"
End Sub
Last edited by jcis; Mar 30th, 2006 at 01:30 PM.
-
Mar 31st, 2006, 04:11 AM
#5
Thread Starter
Member
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
-
Mar 31st, 2006, 08:07 PM
#6
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
-
Apr 4th, 2006, 05:28 AM
#7
Thread Starter
Member
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?
-
Apr 4th, 2006, 08:37 AM
#8
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."
-
Apr 4th, 2006, 12:35 PM
#9
Re: using flexgrid to make a graph
 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.
-
Apr 11th, 2006, 02:14 PM
#10
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|