Results 1 to 2 of 2

Thread: How to Create a grid of buttons

  1. #1
    krazineurons is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2007
    Posts
    2
    Reputation
    0

    Lightbulb How to Create a grid of buttons

    Hi friends, i plan to develop a solution to the Eight Queens Puzzle. Now i got the code to work in VB.NET 2005 however i thought of learining Expressions Blend with the help of making a solver in it. So i thought of the following idea.

    I'l put a 8x8 board with 64 buttons on it. Say the user puts a queen on one of the buttons then in that case all the buttons where the queen can attack should change their background color, (initially Red) and should change to Green. I wanted some thing like this:-


    in the buttons' click event i want the following code (something similar)

    retrive list of all coordinates which fall in the attack zone of the selected button, (i get the list of all horizontal, vertical and diagonal coordinates) in the form of (Row,Column) -> this code part is done



    now the real problem. As i said earlier i want a grid of buttons in such a way that i can access every button in the way:-



    Button(Row,Column) - I can directly pass the Row,Column value and the corresponding button will change it's background color like a function change_color(row,column) where in button(row,column).backcolor = "Green"


    NOW HOW DO I CREATE SUCH GRID OF BUTTONS IN EXPRESSIONS BLEND? in vb i used to work with control arrays, is there anything like that or simpler than that in Expressions Blend.



    Any further suggestions are alse welcome which can improvise my idea or a new methods are also welcome..please help me asap!



    Thanx and Regards
    Anirudh

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,458
    Reputation
    1013
    it's still possible to create an array of buttons, you can't do it in the designer like in vb6. I would declare the array of buttons at the module level, then in the form's load event simply set each element in the array to a new instance of button and set it's top and left property to where they all should be.
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •