Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 图片框点击不';行不通_C#_Picturebox - Fatal编程技术网

C# 图片框点击不';行不通

C# 图片框点击不';行不通,c#,picturebox,C#,Picturebox,这是我有问题的一个表单的全部代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace office {

这是我有问题的一个表单的全部代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace office
{
    public partial class Form2 : Form
    {


    public Form2()
    {
        InitializeComponent();
    }

    private void pictureBox1_Click(object sender, EventArgs e)
    {
        if (Variables.lightsoff == false)
        {
            pictureBox1.Image = office.Properties.Resources.switch_off_icon;
            Variables.lightsoff = true;
        }
        else
        {
            pictureBox1.Image = office.Properties.Resources.switch_on_icon;
            Variables.lightsoff = false;
        }

    }

    private void pictureBox4_Click(object sender, EventArgs e)
    {
        if (Variables.screenoff == true)
        {
            Variables.screenoff = false;
        }
        else
        {
            Variables.screenoff = true;
        }


    }

    private void pictureBox3_Click(object sender, EventArgs e)
    {
        string path;
        OpenFileDialog file = new OpenFileDialog();
        if (file.ShowDialog() == DialogResult.OK)
        {
            path = file.FileName;
            MessageBox.Show("File has been printed!");
        }

    }

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (checkBox1.Checked == true)
        {
            trackBar1.Visible = true;
            label9.Visible = true;

        }

    }

    private void button2_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private void pictureBox2_Click(object sender, EventArgs e)
    {

    }

    private void pictureBox5_Click(object sender, EventArgs e)
    {
        Bookstore Bookstore = new Bookstore();
        Bookstore.ShowDialog();
    }

    private void pictureBox6_Click(object sender, EventArgs e)
    {
        Buffet Buffet = new Buffet();
        Buffet.ShowDialog();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        EventsCalendar Events = new EventsCalendar();
        Events.ShowDialog();
    }

    private void button3_Click(object sender, EventArgs e)
    {

    }

    private void Form2_Load(object sender, EventArgs e)
    {
        string constring = "datasource=localhost;port=3306;username=root;password=salala;" ;
        string Query = "select * from apps.events ";
        MySqlConnection conDatabase = new MySqlConnection(constring);
        MySqlDataAdapter da = new MySqlDataAdapter(Query, conDatabase);
        conDatabase.Open();
        DataSet ds = new DataSet();
        da.Fill(ds, "select");
        DataTable dt = new DataTable();
        dt = ds.Tables["select"];
        foreach (DataRow dr in dt.Rows)
        { 
            listBox1.Items.Add(dr["event_name"].ToString() + " | " + dr["event_description"].ToString() + " | " + dr["event_date"].ToString() + " | " + dr["event_time"].ToString() + " | " + dr["event_duration"].ToString() + " | " + dr["notification_type"].ToString() + " | " + dr["event_type"].ToString());

        }

    }


}
}    
我不知道为什么,但唯一对调试有效的是复选框。没有一个pictureboxes可以工作。数据库运行良好。
有什么建议吗?提前感谢

form2.designer最终出现了问题,但我仍然不知道是什么导致了这个问题

您是否检查了form2.designer.cs中是否附加了事件?