Help with FillRectangle in VB.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Staas
    New Member
    • Nov 2010
    • 1

    Help with FillRectangle in VB.net

    I'm looking for a little help; I've tried everything. Here is a little section of code of a bigger project. What do I need to plug into the ? in the FillRectangleRe ctangle call to get this to work? I got the FillRect... example from MSDN, but I can't figure out how to call it correctly.

    Thanks for any help.
    -Bob

    Code:
    Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
    Dim i As Integer
    Dim pt As Point
    
    Label1.Text = "X=" & MousePosition.X & " Y=" & MousePosition.Y & " "
    pt = New Point(MousePosition.X, MousePosition.Y)
    For i = 0 To 117
    If rects(i).Contains(pt) Then
    Beep()
    FillRectangleRectangle(?, i)
    End If
    Next i
    End Sub
    
    
    Public Sub FillRectangleRectangle(e As System.Windows.Forms.PaintEventArgs, ByVal i As Integer)
    Dim blueBrush As New SolidBrush(Color.Blue)
    
    e.Graphics.FillRectangle(blueBrush, rects(i))
    End Sub
    Last edited by Meetee; May 27 '11, 08:22 AM. Reason: please use code tags
  • David Gluth
    New Member
    • Oct 2010
    • 46

    #2
    You copied a FillRectangleRe ctangle from a place that tried to use it as an event andeler (byval e as ...Eventargs). All you need to do is call the graphic method.
    Code:
      Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
            Dim i As Integer
            Dim pt As Point
    
            Label1.Text = "X=" & MousePosition.X & " Y=" & MousePosition.Y & " "
            pt = New Point(MousePosition.X, MousePosition.Y)
            For i = 0 To 117
                If rects(i).Contains(pt) Then
                    Beep()
                    Dim blueBrush As New SolidBrush(Color.Blue)
                     Graphics.FillRectangle(BlueBrush,rects(i)
                    'FillRectangleRectangle(?, i) 
                End If
            Next i
        End Sub

    Comment

    Working...