这是我有问题的其中一种形式的完整代码
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());
}
}
}
}
我不知道为什么,但唯一适用于调试的是复选框。没有图片框工作。数据库工作正常。 有什么建议?提前谢谢
答案 0 :(得分:0)
最终这是form2.designer的一个问题,但我仍然不知道是什么导致了这个问题