T
T
Taboon2019-05-25 15:15:41
C++ / C#
Taboon, 2019-05-25 15:15:41

How to implement click on objects in WinForm in picturebox via coordinates?

there is a class:

class MapObject
    {
        public string Name;

        public int X;
        public int Y;

        public int Width;
        public int Height;
    }

there is a form where there is a picturebox and on it you need to find objects by coordinates on click here is the code, help me to finalize it:
public Form4()
        {
            InitializeComponent();


            objects = new List<MapObject>();

            objects.Add(new MapObject()
            {
                Name = "Парусник",
                X = 193,
                Y = 35,
                Width = 32,
                Height = 40
            });
        }

        List<MapObject> objects;
private void pictureBox4_MouseClick(object sender, MouseEventArgs e)
        {
            int currentX = e.X;
            int currentY = e.Y;
            for (int i = 0; i < objects.Count; i++)
            {
                objects[i].X
            }
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question