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
Printable View
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
You can use a Chart control or a Picturebox, then just get your values in a loop while you draw them.
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?
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
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
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
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?
Did you ever try RMChart?
Send a PM to Lintz, I think he used this control.Quote:
Originally Posted by fishbyname
cheers for the tip off about lintz, works a treat now
thanks