drawing lines

  • Thread starter Thread starter Vishruth
  • Start date Start date
V

Vishruth

I would like to know how to plot coordinates in the form
using drawline method .For eg: Given only x and y fields
and about 50 records are there in database .I should fetch
the records from database and plot it in the form given
only x and Y coordinates.
please help me to tackle this problem.
 
Vishruth said:
I would like to know how to plot coordinates in the form
using drawline method .For eg: Given only x and y fields
and about 50 records are there in database .I should fetch
the records from database and plot it in the form given
only x and Y coordinates.
please help me to tackle this problem.

Pseudo-Code:

sub render(g as graphics)

for
g.drawXYZ
next

end sub

In OnPaint, call
render(e.graphics)

Outside OnPaint (inside the Form):

dim g as graphics
g = me.creategraphics
try
render g
finally
g.dispose
end try



See also:
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondrawingeditingimages.asp
 
I Didnt have time to finish this, but its almost there. . .

Me.CON = New System.Data.OleDb.OleDbConnection
'
'CON
'
Me.CON.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Documents and
Settings\Administrator\My Documents\" & _
"FamilyPlusFriends.mdb"";Jet OLEDB:Engine
Type=5;Provider=""Microsoft.Jet.OLEDB.4.0" & _
""";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security
info=False;Ext" & _
"ended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt
Database=False;Jet OLED" & _
"B:Create System Database=False;Jet OLEDB:Don't Copy Locale on
Compact=False;Jet " & _
"OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet
OLEDB:Global Bulk T" & _
"ransactions=1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(392, 357)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.CON = New System.Data.OleDb.OleDbConnection
'
'CON ( The Connection to the access Database )
'
Me.CON.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Documents and
Settings\Administrator\My Documents\" & _
"FamilyPlusFriends.mdb"";Jet OLEDB:Engine
Type=5;Provider=""Microsoft.Jet.OLEDB.4.0" & _
""";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security
info=False;Ext" & _
"ended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt
Database=False;Jet OLED" & _
"B:Create System Database=False;Jet OLEDB:Don't Copy Locale on
Compact=False;Jet " & _
"OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet
OLEDB:Global Bulk T" & _
"ransactions=1"


Dim SQLStr As String = "Select * From PLOT"

Dim myCommand As New OleDb.OleDbCommand(SQLStr, CON)
CON.Open()


Dim blackPen As New Pen(Color.Black, 10)

' Draw line to screen.
Dim g As Graphics = Me.CreateGraphics()

Dim lastX, lastY As Integer


RDR = myCommand.ExecuteReader()
' Always call Read before accessing data.
While RDR.Read()

g.DrawLine(blackPen, lastX, lastY, RDR.GetInt32(0),
RDR.GetInt32(1))

lastX = RDR.GetInt32(0)
lastY = RDR.GetInt32(1)


End While
' always call Close when done reading.
RDR.Close()
' Close the connection when done with it.
CON.Close()
 
Back
Top