Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How best to achieve this ?
Thu, Mar 30 2017 6:03 AMPermanent Link

kamran

Hi

So the problem is this:

1. Given a layout of say 10 rows and 10 columns (100 squares(50 x 50 pixels)) which can be panels / buttons.

2. How best to create them at "runtime" at a given position (using row and column as parameters)  ?  say  

1st button at  coordinate (R,C)      : 2,4          
2nd button at  coordinate (R,C)     : 6,2
3rd button at co-ordinate (R,C)      : 8,3
etc.
so in the above example only three buttons are displayed and
only appear at the given co-ordinates / position specified.

any ideas or suggestions?

regards

Kamran
Thu, Mar 30 2017 6:13 AMPermanent Link

Uli Becker

You know how to create buttons at runtime time?
Then it should be quite easy. Just calculate the top and left positions depending on the coordinates.
If you have problems: what have you tried til now?

Uli
Thu, Mar 30 2017 6:20 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> You know how to create buttons at runtime time?
> Then it should be quite easy. Just calculate the top and left positions depending on the coordinates.

I agree. Create a panel as the parent, divide the width by the number of columns (cell width), make buttons at those locations, parented on the panel, set their width to the cell width. Repeat calculations for veritical dimension.

If you need to access them, you can create an array, set all values to nil, and then assign those that you have present.

And to know which button was clicked, use the Tag to assign something that makes sense. Could be (X * 100) + Y or something that you can decode easily, or something more specific like index into array of objects they represent..

--

Matthew Jones
Thu, Mar 30 2017 6:55 AMPermanent Link

kamran

Hi Uli and Matthew

Cool !!

I will have a go.

Thanks

Kamran


kamran wrote:

Hi

So the problem is this:

1. Given a layout of say 10 rows and 10 columns (100 squares(50 x 50 pixels)) which can be panels / buttons.

2. How best to create them at "runtime" at a given position (using row and column as parameters)  ?  say  

1st button at  coordinate (R,C)      : 2,4          
2nd button at  coordinate (R,C)     : 6,2
3rd button at co-ordinate (R,C)      : 8,3
etc.
so in the above example only three buttons are displayed and
only appear at the given co-ordinates / position specified.

any ideas or suggestions?

regards

Kamran
Image