Results 1 to 9 of 9

Thread: Class property

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    13

    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:
    1. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
    2.         Dim i As Integer
    3.         Dim Xpos, YPos As Single
    4.         Xpos = e.X
    5.         YPos = e.Y
    6.         If MouseButtons.Left Then
    7.             i = i + 1
    8.             X.node(Xpos, YPos)
    9.             X.label1(Xpos, YPos)
    10.        End If
    11.     End Sub

    From my class X, I would like create a circle in picturebox1 in form:
    VB Code:
    1. Public Class X
    2.     Dim X, Y As Single
    3.     Public Property node() As Single
    4.         Get
    5.             PictureBox1.Circle(Xpos, Ypos)
    6.         End Get
    7.         Set(ByVal Value As Single)
    8.             X = Value
    9.             Y = Value
    10.         End Set
    11.     End Property

    I know this is not a correct way as I got some errors. Please give me some guidances.

  2. #2
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    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??

  3. #3
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668

    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.

  4. #4
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    Re: Class property

    Wait ignore what i said above im still trying to figure out what your trying to do,

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    13

    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 :


  6. #6
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    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:
    1. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
    2.         Dim Xpos, YPos As Single
    3.         Xpos = e.X
    4.         YPos = e.Y
    5.         If MouseButtons.Left Then
    6.             PictureBox1.Circle(Xpos, Ypos)
    7.        End If
    8.     End Sub

    i still have no clue what i is for or what x.label1 is?

  7. #7
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409

    Re: Class property

    ok
    then to draw the label

    add a line right below the picturebox1.drawcircle

    VB Code:
    1. dim lbl as new label
    2. lbl.text = i
    3. lbl.Top = Ypos
    4. lbl.Left = Xpos
    5.  
    6. picturebox1.controls.add(lbl)

    and put your i back in

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    13

    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.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    13

    Re: Class property

    Is this correct?

    VB Code:
    1. 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
  •  



Click Here to Expand Forum to Full Width