【发布时间】:2014-12-08 21:02:39
【问题描述】:
我正在开发动漫列表的乐趣和练习,我制作了一个包含 1 个链接标签的用户控件,该链接标签将调用一个表单,我需要将链接标签的标题传递给那个标签我的所有标签和链接标签都设置为公开。
这是我的代码,我正在使用 Visual Studio 2012 mysql 数据库
void ReadLabel()<br>
{
int ctr = 0;
//string myConnection = "datasource=localhost;port=3306;username=root;password=";
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlCommand command = myConn.CreateCommand();
command.CommandText = "Select * FROM maindatabase.animelist";
//command.Parameters.AddWithValue("?parameter",ctr.ToString());
MySqlDataReader myReader;
try
{
ctr++;
myConn.Open();
myReader = command.ExecuteReader();
while (myReader.Read())
{
string Link = myReader["TitleAnime"].ToString();
List li = new List();
//AnimeForm ani = new AnimeForm();
li.linkLabel1.Text = Link;
li.linkLabel1.Click += linkLabel1_Click;
// li.linkLabel1.Click = ani.Show();
//if (li.linkLabel1.Text.Length > 0)
// li.linkLabel1.Text += Environment.NewLine;
flowLayoutPanel1.Controls.Add(li);
button4.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
myConn.Close();
}
void linkLabel1_Click(object sender, EventArgs e)
{
AnimeForm ani = new AnimeForm();
//ani.Title.Text = Link;
ani.Show();
//throw new NotImplementedException();
}
【问题讨论】:
标签: c# mysql visual-studio-2012