draw a rectangle

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • joshguru
    New Member
    • Mar 2008
    • 6

    draw a rectangle

    i have to click a button and draw a rectangle in vb.net form like wise drawing a rectangle in painbrush..give me sample coding
  • osku200
    New Member
    • Mar 2008
    • 2

    #2
    Ok your button isn't included here sorry, it was a bit complex to me(i'm a bit noobie here) so you can figure out yourself anothe way or make it with the button. anyway, here's the code to draw the rect:

    Public Class Form1

    Dim r As New Rectangle(100, 100, 100, 50) 'the rectangle to fill

    Private Sub Form1_Paint(ByV al sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Me.Paint

    Dim g As Graphics = e.Graphics 'graphics class
    g.FillRectangle (Brushes.Black, r) 'draw it

    End Sub
    End Class

    Learned anything? ok, that's it for now. if you want i post more gdi+ help so only ask me.

    Comment

    • joshguru
      New Member
      • Mar 2008
      • 6

      #3
      GIVE ME SAMPLE CODE:
      sir,thank u sir,but i want to draw rectangle freehand in runtime sir....in my form i have one button name rectangle...i want to click that button and draw rectangle freehand in runtime.....
      sorry for inconvenience sir.
      thnak u sir..

      Comment

      Working...