|
-
Jan 16th, 2005, 09:10 PM
#1
Thread Starter
New Member
Class property
Hi,
I have a class X and I would like create an instance of class X from Form1 according to the mousebutton click and location of the click
VB Code:
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim i As Integer
Dim Xpos, YPos As Single
Xpos = e.X
YPos = e.Y
If MouseButtons.Left Then
i = i + 1
X.node(Xpos, YPos)
X.label1(Xpos, YPos)
End If
End Sub
From my class X, I would like create a circle in picturebox1 in form:
VB Code:
Public Class X
Dim X, Y As Single
Public Property node() As Single
Get
PictureBox1.Circle(Xpos, Ypos)
End Get
Set(ByVal Value As Single)
X = Value
Y = Value
End Set
End Property
I know this is not a correct way as I got some errors. Please give me some guidances.
-
Jan 16th, 2005, 09:31 PM
#2
Hyperactive Member
Re: Class property
Public Property node(Xpos As single, YPos As Single) As Single
um also im not sure what your trying to return with this property??
-
Jan 16th, 2005, 09:32 PM
#3
Fanatic Member
Re: Class property
This looks like a mess to me... I don't think the property method works the way you want this too....
If wishes were fishes we'd all cast nets.
-
Jan 16th, 2005, 09:32 PM
#4
Hyperactive Member
Re: Class property
Wait ignore what i said above im still trying to figure out what your trying to do,
-
Jan 16th, 2005, 09:34 PM
#5
Thread Starter
New Member
Re: Class property
I am sorry, maybe I was not clear of what my intention of my program.
I would like to draw a circle as an object with every mouseclick in a picturebox. The location of the circle is based on the location of the mouseclick. I would also like every circle to be labeled, eg. "circle1", "circle2", "circle3".... and every circle will have a property at the later stage.
That is actually what I am planning to do :
-
Jan 16th, 2005, 09:35 PM
#6
Hyperactive Member
Re: Class property
ok im not sure why your useing a class but its not really a situation where you use one
try:
VB Code:
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim Xpos, YPos As Single
Xpos = e.X
YPos = e.Y
If MouseButtons.Left Then
PictureBox1.Circle(Xpos, Ypos)
End If
End Sub
i still have no clue what i is for or what x.label1 is?
-
Jan 16th, 2005, 09:37 PM
#7
Hyperactive Member
Re: Class property
ok
then to draw the label
add a line right below the picturebox1.drawcircle
VB Code:
dim lbl as new label
lbl.text = i
lbl.Top = Ypos
lbl.Left = Xpos
picturebox1.controls.add(lbl)
and put your i back in
-
Jan 16th, 2005, 09:38 PM
#8
Thread Starter
New Member
Re: Class property
Actually the I am using a class for every circle drawn because I am writing a simulation where every circle is representing a node in a network. Therefore every node will have a certain property.
I guess I am right on this.
-
Jan 16th, 2005, 09:45 PM
#9
Thread Starter
New Member
Re: Class property
Is this correct?
VB Code:
PictureBox1.Circle(Xpos, YPos)
'Circle' is not a member of 'System.Windows.Forms.PictureBox'
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
|