1

I currently have a complete game of life program written where nearly everything is done in classes. I'm trying to figure out how to display my 2D array (which is my Game of Life grid) in a windows form picturebox, as currently I only know how to run it in the console.

I'm very new to windows forms so as detailed of help as possible would be great :)

I have a class called Cell which represents each cell in the grid, and a class called GOL which represents a grid. Gol contains methods for setting the live cells and for updating each iteration of the grid in the game.

I know that I need to create a bitmap out of the 2D array, and somehow also use my methods on it, and then display that in the picturebox. No idea how to do any of it.

Thanks :)

3
  • You can create a TableLayoutPanel and draw cells with back colors based on your input array. Also you can dynamically add some controls like panel to TableLayoutPanel having backcolor based on your input array. Commented Oct 15, 2016 at 3:00
  • I'll try that.. once I wrap my mind around where that code would go, how to pass my input array into it, how to make the picturebox display it, etc.. but thank you for pointing me in a direction! Commented Oct 15, 2016 at 3:24
  • My answer doesn't use PictureBox. It relies on TableLayoutPanel instead. Take a look at linked posts. For example in this post I used an array of colors to colorize TableLayoutPanel cells. Commented Oct 15, 2016 at 4:45

1 Answer 1

0

The example for System.Drawing.Bitmap shows setting some pixels and displaying it with a PictureBox. Instead of creating a Bitmap from file you can just create one the same size as your grid new Bitmap(width, height)

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I'll try that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.