K
K
Konstantin Malyarov2017-03-24 23:58:43
C++ / C#
Konstantin Malyarov, 2017-03-24 23:58:43

Why is messagebox not working?

I downloaded VSC 2017 and decided to try writing in C#. In the book it is written that at a double click there will be an additional dialog box. But something is not happening.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Contact List 1.0\nWritten by: 18ko&Ururur", "About");
        }
    }
}

Where is the joint?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Recardo_Recoly, 2017-03-25
@Recardo_Recoly

Well... And in the form you created pictureBox ?
And put an event handler on it?

M
Maxim, 2017-03-25
@Got_Oxidus

Signed up for an event?
It's either in the VS designer or in code.
1. Select the PictureBox -> In the properties window, the button with a lightning bolt -> in the list, look for the desired event (DoubleClick). (a method will appear in the code)
2

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            pictureBox1.DoubleClick += pictureBox1_Click; //!!!!
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Contact List 1.0\nWritten by: 18ko&Ururur", "About");
        }
    }

V
Vasya Pupkin, 2017-03-25
@vasi_pupkin

Push pictureBox from the panel on the left onto the form
It will automatically be called pictureBox1
Then set a click event for
it This code will appear itself

private void pictureBox1_Click(object sender, EventArgs e)
        {
            
        }

it remains only to add
MessageBox.Show("Contact List 1.0\nWritten by: 18ko&Ururur", "About");

K
kvasek, 2017-03-25
@kvasek

Watch in full and then similarly create an event for your pictureBox
https://www.youtube.com/watch?v=Is1EHXFhEe4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question