的Ive有一些问题从MySql.Data.MySqlClientMySQL的读者使用C#
了解MySQL的读者这是我的代码:
while (reader.Read())
{
documentButtons = new RadioButton[3];
for (int i = 0; i < 3; i++)
{
documentButtons[i] = new RadioButton();
documentButtons[i].Text = reader["name"].ToString() + " " + (i + 1);
Console.WriteLine(reader["name"].ToString());
documentButtons[i].Location = new System.Drawing.Point(10, 10 + i * 20);
this.Controls.Add(documentButtons[i]);
}
}
Console.ReadLine();
这使得3个单选按钮与文本:“Dokument1 1 “,”Dokument1 2“,”Document1 3“ 正如你可能看到的,我希望”Dokument“后面的数字等于后面的数字。 (我的3个数据库中的第一个条目是“Dokument1”,“Dokument2”和“Dokument3”。在我的控制台中,“Dokument1”,2和3都显示了3次,我怎样才能使它创建合适的名称适当的单选按钮
为什么for循环在那里,如果你想要的只是三个单选按钮?你正在为每个数据库记录创建三个,它看起来像。 – reallyJim