trouble on displaying ellipse in a user-defined location

junforever

New member
Joined
Oct 21, 2009
Messages
2
Programming Experience
Beginner
:( please help me guys.. im having trouble here..
can u help me with this simple program.

i want to create a form which has:
textbox1, textbox2, button1...

all i want to do is to display an ellipse in a specific location inside the form according to the value i have put in textbox1 and textbox2 for the value of x and y coordinates, respectively...


now, i do not know what code im gonna be putting on button1_click event......


please help me guys...
 
I would use NumericUpDown controls for numeric input, it also have ValueChanged event that I would use to change the drawing parameters and force a repaint. Here's a sample:
VB.NET:
Private ellipseRec As New Rectangle(0, 0, 100, 100)

Private Sub NumericUpDowns_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDownX.ValueChanged, NumericUpDownY.ValueChanged
    ellipseRec.Location = New Point(CInt(Me.NumericUpDownX.Value), CInt(Me.NumericUpDownY.Value))
    Me.Refresh()
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    e.Graphics.DrawEllipse(Pens.Black, ellipseRec)
End Sub
 
Back
Top