Jump to content

C# Pictureboxların Birbirine Teması


mertugruul
 Share

Recommended Posts

Merhaba.

 

2 tane pictureBox'ın var olduğunu düşünelim. pictureBox7 yukarıdan gelecek ve aşağıdaki pictureBox'a temas edince istediğim kodları çalıştırmak istiyorum.

Aşağıdaki şu kod oluyor pic7 pic6'in üstüne geldiğinde ama bazen de 2 pictureBox birbirine değmediği halde yine aşağıdaki kod çalışıyor.

 if ((pictureBox7.Location.X + pictureBox7.Width >= pictureBox6.Location.X) && (pictureBox7.Location.Y + pictureBox7.Height >= pictureBox6.Location.Y))
 {
                    

 }

Başka bir yol varmıdır bundan başka?

Edited by mertugruul
Link to comment
Share on other sites

Rectangle.IntersectsWith() medotu ile sorunsuz kullanabilirsin. Bir zaman öyle kullanmıştım. (MSDN Sayfası)

 

Kontrollün bulunduğu rectangle üzerinden işlem yapıyor. tüm kontrollerde kullanılabilir.

 

kullanım şekli:

if (pbImage7.Bounds.IntersectsWith(pbImage6.Bounds))
{
    // cakisma kodu gelecek.
}

Hala çalışıyosa eğer bu şekilde baya tutarlı oluyordu

Edited by Bitmap
Link to comment
Share on other sites

Rectangle.IntersectsWith() medotu ile sorunsuz kullanabilirsin. Bir zaman öyle kullanmıştım. (MSDN Sayfası)

 

Kontrollün bulunduğu rectangle üzerinden işlem yapıyor. tüm kontrollerde kullanılabilir.

 

kullanım şekli:

if (pbImage7.Bounds.IntersectsWith(pbImage6.Bounds))
{
    // cakisma kodu gelecek.
}

Hala çalışıyosa eğer bu şekilde baya tutarlı oluyordu

 

İlaç gibi geldi. Sağolasın.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...