473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

change the location of a group of buttons

Prathap
37
I have 25 buttons in a form.
Here is the code below that i have used to change the location of One button at run time.
Expand|Select|Wrap|Line Numbers
  1. Public Class table
  2.     Private dragging As Boolean
  3.     Private beginX, beginY As Integer
  4.     Private Sub Button1_mousedown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
  5.         dragging = True
  6.         beginX = e.X
  7.         beginY = e.Y
  8.     End Sub
  9.     Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
  10.         If dragging = True Then
  11.             Button1.Location = New Point(Button1.Location.X + e.X - beginX, Button1.Location.Y + e.Y - beginY)
  12.             Me.Refresh()
  13.         End If
  14.     End Sub
  15.     Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
  16.         dragging = False
  17.     End Sub
  18. End Class
Now i want to Change the location of remaining 24 buttons.So, should i write this code for all those buttons or is there any easier way to do the same?
Could someone please help?
Dec 22 '11 #1
1 2600
IronRazer
83 64KB
Hello Prathap,
Are the buttons going to be placed randomly or do you want to keep them in the same order and just move them all? If you want to keep them in the same order then you could try placing them all onto a Panel and use your code to move the whole Panel. If you want to move them around one by one and place them in a random spot then I think you will need to write this for each button.
Jan 19 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bryan | last post by:
Hi, I have a form that I want to click a button on and cause the location.href to change. this is what I used: the function: function testform(){ location.href="http://www.google.com" }
2
by: Ken Baltrinic | last post by:
Don't ask my why we need to do this, I didn't write the website policy :( , but we are deploying to a website where we cannot place any directories directly off web root (i.e. aspnet_client) and...
2
by: monomaniac21 | last post by:
Hi all is it possible to get a button in an iframe to change location of parent page? regards marc
1
by: libsfan01 | last post by:
Hi all is it possible to get a button in an iframe to change location of parent page? regards marc
5
by: Student1000 | last post by:
Help me out please... Ok, i have been trying to do this for months….I kinda gave up on it but am back at it again. I created a form for a table (Bills). In the form, I have three option buttons...
2
by: nico3334 | last post by:
Hi, I have a SQL table that has data like this: Title Month Info 1 ---- 7 ---- 100 1 ---- 7 ---- 100 1 ---- 8 ...
5
by: sanishr | last post by:
I want to change my group from primary group to secondary or viceversa. I don't have superuser access also. could anybody please let me know how to do this.
0
by: DFriija | last post by:
Hi, My application wants to run on two screens, one for the backoffice and another for the public. The public wants to make run a ppt when the screen is much idle time, my problem is when I do ...
11
tuxalot
by: tuxalot | last post by:
Another quick question for ya... Here's my button code, and I want to see if I can do something different so I don't have to repeat the same code for each of my 14 buttons in my option group: ...
1
by: wayne smith | last post by:
Hi, I am building a inventory system using ms access. Each inventory id can be from different regions. In one form, users enter the inventory id and if there is more than one region, another form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.