By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

drawing lines

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Vishruth" <ra************@rediffmail.com> schrieb
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...tingimages.asp
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
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()

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.