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 8171431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:27:33+00:00 2026-06-06T21:27:33+00:00

I have chess table and my elements are now moving according to rules .But

  • 0

I have chess table and my elements are now moving according to rules .But when I drag out of rules my button is disappearing…How I can solve it ???
(red buttons are showing where can I go my elements)
for example knight is moving as rules now (if I don’t pass over the red buttons there is no problem)but when I pass over the red places and if I drop there the knight disappears and red places turns back to their original color ( no more red places which indicates where my knight can go ). i tried to make debug but since i am new in c# and debugging i haven’t solved the problem. i will be happy if u enlighten my way. how can i solve it? thanks

        void btn_DragEnter(object sender, DragEventArgs e)
        {
        Button button = (Button)sender;
        e.Effect = DragDropEffects.Move;
        for (int x = 0; x <= 7; x++)
        {
        for (int y = 0; y <= 7; y++)
        {
        btn[x, y].Image = null;
        if ((x + y) % 2 == 0)
        btn[x, y].BackColor = Color.Black;
        else
        btn[x, y].BackColor = Color.White;
        }
        }
        }

        void btn_DragDrop(object sender, DragEventArgs e)
        {
        Button button = (Button)sender;
        button.Image = (Bitmap)e.Data.GetData(DataFormats.Bitmap);

        int[] dizi = (int[])button.Tag;
        int x = dizi[0];
        int y = dizi[1];

        for (int a = 0; a <= 7; a++)
        {
        for (int b = 0; b <= 7; b++)
        {
        btn[a, b].AllowDrop = false;
        }
        }

        if ((x + 1 >= 0 && y + 2 <= 7) && (y + 2 >= 0 && x + 1 <= 7))
        {
        btn[x + 1, y + 2].BackColor = Color.Red;
        btn[x + 1, y + 2].AllowDrop = true;
        }
        if ((x + 1 >= 0 && y - 2 <= 7) && (y - 2 >= 0 && x + 1 <= 7))
        {
        btn[x + 1, y - 2].BackColor = Color.Red;
        btn[x + 1, y - 2].AllowDrop = true;
        }
        if ((x - 1 >= 0 && y + 2 <= 7) && (y + 2 >= 0 && x - 1 <= 7))
        {
        btn[x - 1, y + 2].BackColor = Color.Red;
        btn[x - 1, y + 2].AllowDrop = true;
        }
        if ((x - 1 >= 0 && y - 2 <= 7) && (y - 2 >= 0 && x - 1 <= 7))
        {
        btn[x - 1, y - 2].BackColor = Color.Red;
        btn[x - 1, y - 2].AllowDrop = true;
        }
        if ((x + 2 >= 0 && y + 1 <= 7) && (y + 1 >= 0 && x + 2 <= 7))
        {
        btn[x + 2, y + 1].BackColor = Color.Red;
        btn[x + 2, y + 1].AllowDrop = true;
        }
        if ((x + 2 >= 0 && y - 1 <= 7) && (y - 1 >= 0 && x + 2 <= 7))
        {
        btn[x + 2, y - 1].BackColor = Color.Red;
        btn[x + 2, y - 1].AllowDrop = true;
        }
        if ((x - 2 >= 0 && y + 1 <= 7) && (y + 1 >= 0 && x - 2 <= 7))
        {
        btn[x - 2, y + 1].BackColor = Color.Red;
        btn[x - 2, y + 1].AllowDrop = true;
        }
        if ((x - 2 >= 0 && y - 1 <= 7) && (y - 1 >= 0 && x - 2 <= 7))
        {
        btn[x - 2, y - 1].BackColor = Color.Red;
        btn[x - 2, y - 1].AllowDrop = true;
        }
        }
  • 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-06-06T21:27:35+00:00Added an answer on June 6, 2026 at 9:27 pm

    DoDragDrop is called only when actually dropping the piece. Your logic for determining where the piece can be dropped should be run when starting the drag, in MouseDown or MouseMove, before the call to DoDragDrop. It also seems you are clearing the red buttons in the DragEnter function. That also should be done in the MouseDown/MouseMove function, after the call to DoDragDrop.

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

Sidebar

Related Questions

first, I can't stand Crystal! Okay, that's off my chest... Now, we have an
I have experienced AlphaBeta algorithm with my own old chess engine and now i
I have a problem with implementing a simple NegaMax in my chess programm. According
I wana develop a multi-player chess using c# but I don't have any idea
I have created a chess board in php, and put the chess piece according
I'm currently debugging my transposition table for a chess variant engine where pieces can
I have a problem in a class I can't solve, the loop breaks in
Display the details of the employees who have subscribed for Football and Chess but
I have made this chess game, but i need help with the accept setting
I have series of divs, that represent similar to a chess board. but this

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.