我得到的对象未设置为对象的实例,但我不知道为什么。我把布景弄对了吗?
KandidaatNamen的值为Sophie,但LabelKandidaatNaam的值为null。 LabelKandidaatNaam必须是Sophie的值。
Ukandidaten表格
public string KandidaatNaam
{
set
{
KandidaatNamen = value;
LabelKandidaatNaam.Text = KandidaatNamen;
}
get
{
return KandidaatNamen;
}
}
创建uPartijen
private void ButtonPartij_Click(object sender, EventArgs e)
{
Database con = new Database();
if (_Form1.idPartijen.Contains(labelNummer.Text))
{
con.SqlQuery("SELECT * FROM `kandidaat` where `partijnummer` =@nummer ");
con.Cmd.Parameters.Add("@nummer", MySql.Data.MySqlClient.MySqlDbType.VarString).Value = labelNummer.Text;
Kandidatenlist = new List<uKandidaten>();
idKandidaten = new List<string>();
foreach (DataRow dr in con.QueryEx().Rows)
{
uKandidaten proitem = new uKandidaten(this);
Voornaam = dr[2].ToString();
Achternaam = dr[3].ToString();
NummerKandidaat = dr[6].ToString();
proitem.KandidaatNaam = Voornaam;
proitem.KandidaatAchterNaam = Achternaam;
proitem.KandidaatNummer = NummerKandidaat;
Kandidatenlist.Add(proitem);
}
_Form1.panelPartijen.Controls.Clear();
_Form1.panelPartijen.Controls.AddRange(Kandidatenlist.ToArray());
}