|
-
May 15th, 2008, 08:33 PM
#1
Thread Starter
New Member
[2005] Random Buttons Problem
I have to design a program for my school where i have a set of 50 buttons that when i click a button go into a random order.
My problem is, is when i click the button they all over lap each other.
So i need help in finding a way to make it so they are all separated and not overlapping each other.
Also is there away to use a button as a array like
Button1.top = blah blah turn that into
Button(i).top = blah blah
(for a for i loop that is)
-
May 15th, 2008, 08:59 PM
#2
Re: [2005] Random Buttons Problem
1. Use a TableLayoutPanel. It will only accept one control in each cell so they are all laid out in a table automatically.
2. An array of Buttons, or any control for that matter, is created in code just like any other array. That said, can access controls in a TableLayoutPanel by column and row index, so that may be easier.
-
May 15th, 2008, 10:45 PM
#3
Thread Starter
New Member
Re: [2005] Random Buttons Problem
 Originally Posted by jmcilhinney
1. Use a TableLayoutPanel. It will only accept one control in each cell so they are all laid out in a table automatically.
Ok cheers for this i will check it out later
 Originally Posted by jmcilhinney
2. An array of Buttons, or any control for that matter, is created in code just like any other array. That said, can access controls in a TableLayoutPanel by column and row index, so that may be easier.
So to make a button array without TableLayoutPanel i need certain code? What is this code?
Thanks
-
May 15th, 2008, 10:51 PM
#4
Re: [2005] Random Buttons Problem
Have you ever created an array of Strings or Integers or something like that? An array of Buttons is exactly the same.
http://startvbdotnet.com/language/arrays.aspx
-
May 15th, 2008, 10:56 PM
#5
Thread Starter
New Member
Re: [2005] Random Buttons Problem
 Originally Posted by jmcilhinney
Well i have in visual basic six but not studio.
Anyway heres the code i have (example)
Dim i as Integer
For i = 1 to 40
button(i).top = 465
button(i).left = 300
Next
But it gives me a error when i do this.
-
May 16th, 2008, 12:24 AM
#6
Re: [2005] Random Buttons Problem
 Originally Posted by Shadow-Walker
Well i have in visual basic six but not studio.
Anyway heres the code i have (example)
Dim i as Integer
For i = 1 to 40
button(i).top = 465
button(i).left = 300
Next
But it gives me a error when i do this.
This is because there are no control arrays in .net.
-
May 16th, 2008, 01:22 AM
#7
Re: [2005] Random Buttons Problem
Control arrays as they existed in VB6, i.e. created in the designer, are not supported in VB.NET. As i have already said, an array of controls can be created in code just like any other array. Did you follow the link I provided? If so then you know how to create an array in code.
-
May 16th, 2008, 04:47 AM
#8
Re: [2005] Random Buttons Problem
A similar thing that you are trying to do can be done like this.
Code:
Dim g As New Button
Dim hs As New Button
g.Name = "pro"
hs.Name = "ko"
Dim go As New List(Of Button)
go.Add(g)
go.Add(hs)
go.Item(1).Top=
go.Item(1).Left=
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|