why wont my rect move on my form?

im just trying to move myRect, a rectangle, around the form....................
why doesnt dis work?!!!!!!!!!!!!!!!!!!!!!!!:mad: :confused: :mad:


VB.NET:
Public Class Form1[INDENT]Private myRectPoint As New Point[/INDENT][INDENT]Private myRectSize As New Size[/INDENT][INDENT]Const cintRectSize As Integer = 600[/INDENT][INDENT]Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load[/INDENT][INDENT]myRectPoint.X = 10[/INDENT][INDENT]myRectPoint.Y = 50[/INDENT][INDENT]myRectSize.Height() = cintRectSize[/INDENT][INDENT]myRectSize.Width() = cintRectSize[/INDENT][INDENT]End Sub[/INDENT][INDENT]Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint[/INDENT][INDENT]Dim yourRect As New Rectangle(myRectPoint, myRectSize)[/INDENT][INDENT]With e.Graphics[/INDENT][INDENT].DrawRectangle(Pens.DarkGoldenrod, yourRect)[/INDENT][INDENT]End With[/INDENT][INDENT]End Sub[/INDENT][INDENT]Private Sub upButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _[/INDENT][INDENT]Handles upButton.Click, downButton.Click, leftButton.Click, rightButton.Click[/INDENT][INDENT]Dim tButton As New Button[/INDENT][INDENT]tButton = CType(sender, Button)[/INDENT][INDENT]Select Case tButton.Tag()[/INDENT][INDENT]Case "up"[/INDENT][INDENT]myRectPoint.Y() += 100[/INDENT][INDENT]Case "down"[/INDENT][INDENT]Case "left"[/INDENT][INDENT]Case "right"[/INDENT][INDENT]End Select[/INDENT][INDENT]End Sub[/INDENT]End Class
 
Last edited:
I could be wrong, but i think point.x and point.y are read only.

what you need to do is replace

myRectPoint.Y() += 100
with

myRectPoint= new Point(myRectPoint.X,myRectPoint.Y + 100)
 
No they are not read only, you just need to invalidate the form after you have adjusted the rectangles location..

VB.NET:
 [INDENT]Case "up"[/INDENT][INDENT]myRectPoint.Y() += 100
 
Me.Invalidate
[/INDENT]
 
whatever invalidate is.....................

it doesnt sound to interesting to HAVE to jump over................................................................................................................

i put my grids on an "expanding when needed" mdi child form.

its just an editor that im making............but r.a.d. for the invalidating comment though, thanks

invalidate..........

p.s........... and correct me if im wrong but, wont SOME of the people who know binary, be responsalble for the worst hacking alive?
I can make a .bmp from a hex editor, and i stopped there with that kind of "bit by bit interfacing".
I wish this world were more r.a.d. .
 
Last edited:
Have you been smoking something?

Binary is a number format, not a programming language, it's a play on words becuase Bin (10) = Dec (2), therefore the 2 types...

vis781 means that you should invalidate the region that your rectangle has been drawn on by using (for example)

Me.Invalidate()

This causes the system to redraw that area.

An alternative is Me.Refresh() which causes the area to be redrawn immediately, whereas invalidate lets the system do it when it is ready.
 
and your . key seems to be stuck. :)
 
Back
Top