Some Useful .NET Codes
Here will be some useful .NET tutorials for you programs. Please post what you think are some useful codes that will help people in .NET. I will start off
:
This will move the form when you drag PictureBox1, you can change what control to move it with, replace all "PictureBox1"s with your desired control (eg Label1, Form1, etc). You can also make it to drag other controls, simply replace all "Me.Location" with "YOUR CONTROL.Location"
You can also loop this so that it will slide across your screen until it gets to the right location;
And then reverse it, very easy for slide-down control panels etc.
Note: Im pretty sure you need to have both .X and .Y, if you dont want to change one of them just dont put any numbers.
I like to put this in a timer and if it finds the program it changes a labels text to green, and says "Found!" else the text is red and says "Not Found!". Up to you though.
Thread Rules:
- No double posts
- Do not swear/use Inappropriate language please
- Only post codes that are not harmful to users computers
- No outside linking, replace websites etc with "You text here"
- The usual Forum/Thread rules
- If you use a code from this thread, credit the poster of that code!
Sticky?
:Moving A Border-less form
Code:
Dim Moveable As Boolean
Dim LastPos As Point
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Moveable = True
LastPos = Cursor.Position - Me.Location
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If Moveable Then
Me.Location = Cursor.Position - LastPos
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Moveable = False
End Sub
Change Location X/Y
Code:
PictureBox1.Location = New Point(PictureBox1.Location.X = 15, PictureBox1.Location.Y = 91)
Code:
If Picturebox1.Location.Y = 30 Then
Do Until PictureBox1.Location.Y = 15
PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y -1)
Loop
End If
Note: Im pretty sure you need to have both .X and .Y, if you dont want to change one of them just dont put any numbers.
Search For Program
Code:
myProcesses = Process.GetProcessesByName("YOUR PROCESS") 'Do not include the extension (.exe)
If myProcesses.Count > 0 Then
MsgBox ("Found!")
Else
MsgBox ("Not Found!")
End If
Thread Rules:
- No double posts
- Do not swear/use Inappropriate language please
- Only post codes that are not harmful to users computers
- No outside linking, replace websites etc with "You text here"
- The usual Forum/Thread rules
- If you use a code from this thread, credit the poster of that code!
Sticky?






