Hello,
how do i lock my form in place when i press a checkbox and unlock it by unchecking it ?
sorry for noob question![]()
Hello,
how do i lock my form in place when i press a checkbox and unlock it by unchecking it ?
sorry for noob question![]()
Sub handling checkbox value changed
If form is locked then unlock form
If form is not locked then lock form
End Sub
There's an algorithm for it. Just turn it into vb code (for handling, do something like this: Private Sub Whatever() Handles Checkbox1.Changed (I don't remember the exact event name)) and you're sorted.
made it look like thisbut now i get the error value of type form1 can not be converted to integerPrivate Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.CheckState = CheckState.Checked Then Lock(Form1)
It needs to be :
Code:Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.CheckState = CheckState.Checked Then Lock(ME)
Why fill up a signature?
i still get same error
Lol.
The Lock keyword is for thread synchronization. (Locks the current sub from being accessed until it hits the end of the lock statement, so threads don't try to use the same sub at the same time, ending up in bad bugs)
You'd need to do some window border changing I think. (Not sure why you'd want to lock the form in place at all...) Just google for a way to do it.
i wanna lock it so i don't accidentally move it , and i googled but the guides i found was a bit to complicated for a noob like me![]()
Code:Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked Then Me.Locked = True End Sub
Locks the form in place so it can't be resized or moved if you check the checkbox. Coded in VB.NET 2008.
Last edited by ReidE96; 10-07-2008 at 10:54 AM. Reason: Borked me code tags
*sigh* error againLocked is not a member of form1
o.0 Ok, plan b.
Replace the width and height with the width and height you want it to stay as.Code:Private Sub Form_Resize() Handles Me.ResizeEnd If Checkbox1.Checked then Me.Size.Width = widthgoeshere Me.Size.Height = heightgoeshere End If End Sub
no i don't want to lock the size feature just so u can't Move it![]()
Globals
Checkbox ChangedCode:Dim FormX, FormY as integer
Form MovedCode:Private Sub Checkbox_Changed() Handles Checkbox1.CheckedChanged If Checkbox1.Checked Then FormX = Me.Location.X FormY = Me.Location.Y End If End Sub
Replace Checkbox1 with your checkbox's name.Code:Private Sub Form_Moved() Handles Me.LocationChanged If Checkbox1.Checked Then Me.Location.X = FormX Me.Location.Y = FormY End If End Sub
Edit:
I could have just made it as before where it was locked in one place, but I'm guessing you might want to lock it in various locations, so I made it capable of that.
thank you but where do i find the "Global" thingy xd
Anywhere inside the main class
Code:Public Class frmMain Dim FormX, FormY as Integer
error xd (Me.Location.Y and Me.Location.X)
expression is a value and therefore cannot be the target of an assignment
Private Sub CheckBox1_locationchanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.LocationChanged
If CheckBox1.Checked Then
Me.Location.X = FormX
Me.Location.Y = FormY