.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Moving button using mouse event.

Posted By:laptop charles       Posted Date: July 29, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Moving button using mouse event.which is used a funny.
 

*It contain two button one is drag and drop then it's text is "Yes"and other one is created at runtime.
*It has one label is the text "Are You Fool?".
*Then run the appication.
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private WithEvents cha As Button

    Dim a, b, a1, b1 As Integer
     

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cha = New Button
        cha.SetBounds(496, 112, 75, 23)
        cha.Text = "No"
        Me.Controls.Add(cha)
        
    End Sub

    Private Sub cha_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles cha.MouseEnter
       
        cha.Hide()

       

        If a1 < 700 And b1 < 500 Then


            cha = New Button

            cha.SetBounds(a + a1 - 10, b + b1 - 20, 75, 23)
            cha.Text = "No"
            Me.Controls.Add(cha)

            
        ElseIf b1 < 500 Then
            cha = New Button

            cha.SetBounds(a1 - 600, b1 - 300, 75, 23)
            cha.Text = "No"
            Me.Controls.Add(cha)
          

        ElseIf a1 < 700 Then
            cha = New Button

            cha.SetBounds(a1 - 200, b1 - 400, 75, 23)
            cha.Text = "No"
            Me.Controls.Add(cha)
            

        End If
        


    End Sub

    

    
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        a = 50
        b = 100
        a1 = e.X
        b1 = e.Y


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("Yes, Great You Are fool")
    End Sub
End Class


     

Further Readings:

Responses
Author: rajendra         Company URL: http://www.dotnetspark.com
Posted Date: August 03, 2010

what are the new concept's in studio2010


Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend