Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3948516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:03+00:00 2026-05-20T01:23:03+00:00

I’m trying to make something of a Tile-Map editor in C# using picture-boxes (the

  • 0

I’m trying to make something of a Tile-Map editor in C# using picture-boxes (the simplest way i could think to throw tiles into a form)

The code that Generates the picture boxes is:

public void Generate_Tiles(int width, int height)
        {
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    System.Windows.Forms.PictureBox picturebox = new PictureBox();
                    picturebox.BackColor = SystemColors.ActiveCaption;
                    picturebox.Cursor = Cursors.Cross;
                    picturebox.Location = new System.Drawing.Point((x*32) + 4, (y*32) + 4);
                    picturebox.Name = x+y+"tile";
                    picturebox.Size = new System.Drawing.Size(32, 32);
                    picturebox.TabIndex = 0;
                    picturebox.TabStop = false;
                    picturebox.Click += new System.EventHandler(TileBox_Clicked));
                    map.Controls.Add(picturebox);
                }
            }
            MessageBox.Show("Done");
        }

That part works, as long as i use a small number of picture boxes at a time (8 by 8 seems to be the maximum that it wants to display in a decent amount of time)

I want to perform some action when the user clicks on a specified picture-box, which is why i have a onclick method, that’s where i run into problems, all the picture-boxes are called… picture-box. As far as i can tell, there’s no way for me to tell which picture-box the user clicked.

I will probably need to remake the way the dynamic form works anyway, since i cant get very many picture boxes, but I think the main problem will still be there, as long as i want it to be dynamic (which i do), not all of the tile-maps will be the same size.

Ive never done anything like this, and I’ve looked for ways to override the onclick event… which i couldn’t find, and i couldn’t find a good tile-engine that’s up to date to use (except for XNA, but that’s a little over the top for a simple tile-editor, i think)

Im likely going in the opposite direction then what i need to be doing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:23:04+00:00Added an answer on May 20, 2026 at 1:23 am

    The sender in your event handler will be the PictureBox which was clicked.

        void TileBox_Clicked(object sender, EventArgs e)
        {
            PictureBox pictureBox = sender as PictureBox;
            if(pictureBox != null)
            {
                //do stuff with your pictureBox
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.