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

  • SEARCH
  • Home
  • 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 3492842
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:48:31+00:00 2026-05-18T11:48:31+00:00

i m writing a simple chess game that has 3pieces,a king and a queen

  • 0

i m writing a simple chess game that has 3pieces,a king and a queen one side and other side just a king,the king and queen should mate alone king with less movements.in this project,first we should get the place of alone king from user and then according to that do other works,i want to know how can i get from user that in which place should king stay?i implemented form with 64 pictureboxes.i will write class for positions,thanks so much

edited:

i wrote this code from Mr Jon Skeet answer:
what mistake does it have?because it doesnt do anything when i click,thanks

PictureBox[,] pic = new PictureBox[8, 8];

public PictureBox SetKingImage(int x,int y)
    {


        pic[x,y].Image=Image.FromFile("pic/siyahsah2.JPG");
        return pic[x, y];
    }

public void GetClickedPicturebox()
    {  
        int x, y;

      for(x=0;x<8;x++)
      {
          for(y=0;y<8;y++)
          {
              pic[x, y] = new PictureBox();

              pic[x, y].Click += (object sender, System.EventArgs e) =>SetKingImage(x, y);


            }
          }
      }
  • 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-18T11:48:31+00:00Added an answer on May 18, 2026 at 11:48 am

    The simplest approach would be to ask the user to click on the relevant picture box. You could determine which PictureBox was clicked on in one of three ways:

    • Subscribe using the same event handler for each PictureBox, but use a Tag within the PictureBox to get the coordinates
    • Subscribe using the same event handler for each PictureBox, but just use the reference to the PictureBox (sender) to find which one it was and get the coordinates appropriately
    • Subscribe using a lambda expression which encapsulates the position, like this:

      for (int x = 0; x < 8; x++) {
          for (int y = 0; y < 8; y++) {
              pictureBoxes[x, y].Click += (sender, args) => SetKingPosition(x, y);
          }
      }
      

    One problem with the latter approach is that unsubscribing from an event via a lambda expression is relatively painful – and you probably want to unsubscribe all the event handlers when the first button is clicked.

    An alternative is to leave the event handlers in place, and ignore them when it’s not the right time 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple chess-playing game. I won't post it all here, but
I'm practising with C, writing simple programs. The little program below should just get
I am writing simple site that requires users and profiles to be handled. The
I writing a simple method which should delete an entity from the database if
I writing simple application that need to make some record of the incoming sound.
I'm writing a simple I/O class in order to use at a multiplayer game.
Writing a simple program that will find exact duplicate files on my computer, but
I writing some simple application that will look for some message ( sms message
Basically I am writing a simple bit of code to increment every one second
I am writing simple game on flex. In the game there are 2 objects

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.