cowsarenotevil Posted July 8, 2003 Posted July 8, 2003 This (http://msdn.microsoft.com/library/d...ationofform.asp) tells me that I should be able to change the position of a form while the program is running, but the location, left, and right members of my form don't seem to exist. (using VB .NET). Thanks. NOTE: I have no clue what I'm doing.:p Quote
Leaders dynamic_sysop Posted July 8, 2003 Leaders Posted July 8, 2003 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Location = New Point(Me.Location.X - 10, Me.Location.Y - 10)'/// move the form left & up by 10 pixels each way. End Sub hope this helps :) Quote
cowsarenotevil Posted July 8, 2003 Author Posted July 8, 2003 Yes, I know how to change the location, but the location doesn't appear to exist... if I have a form called Form1 made with the GUI form maker, when I attempt to move it, location does not appear to be a member of the form. (i.e. Form1.location doesn't exist). I'm sure I'm doing something really stupid, but I'm just starting with VB (though I am pretty good at C/C++) Quote
cowsarenotevil Posted July 8, 2003 Author Posted July 8, 2003 Wait... the "me" stuff seems like it might work. Thanks! Quote
*Experts* mutant Posted July 8, 2003 *Experts* Posted July 8, 2003 Me refers to the class that you are currently coding in. So if you put Me in form it will refer to the form, if you put Me in a button class it will refer to that button. Quote
*Experts* Volte Posted July 8, 2003 *Experts* Posted July 8, 2003 The reason you can't do Form1.Location is because all Forms in .NET are classes; you can't change the location of a class, obviously, only of an instance of the class. You could do this:Dim frm As New Form1() 'create a new instance of the Form1 class frm.Location = New Point(10, 20) 'move the form frm.Show() 'show the formand it would work. As mutant said, Me refers to the *instance* of the class that you are currently working in. Quote
Leaders dynamic_sysop Posted July 8, 2003 Leaders Posted July 8, 2003 Me.Location worked fine from inside a button_Click event for me , so it cant be using "button1" as Me , but still the form:-\ . i guess there are a few ways to skin a cat :D Quote
*Experts* Volte Posted July 8, 2003 *Experts* Posted July 8, 2003 Me will always refer to the class instance you are inside, not the object that is recieving an event. I believe mutant was referring to if you made your own button class:Public Class MyButton : Inherits Button Public Sub ChangeText() Me.Text = "Moooo" End Sub End ClassIf you put that button on your form and called its newly made ChangeText() method, the text of the button would change to "Moooo". Quote
*Experts* mutant Posted July 8, 2003 *Experts* Posted July 8, 2003 I believe mutant was referring to if you made your own button class Yes, that what I meant :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.