我几天都遇到了麻烦。我在运行时创建了一个动态按钮,但它会在下次启动时消失。请帮忙。下面是我的编码。
private void button1_Click(object sender, EventArgs e)
{
createNewTable createTable = new createNewTable();
DialogResult dResult = createTable.ShowDialog();
string table_name = "";
if (dResult == DialogResult.OK)
{
table_name = createTable.tableName;
createTable.Dispose();
}
else if (dResult == DialogResult.Cancel)
{
createTable.Dispose();
}
if(table_name != string.Empty){
Button textbox = new Button();
textbox.Name = "btn_" + table_name;
textbox.Text = table_name;
textbox.Height = 55;
textbox.Width = 123;
textbox.MouseDown += new MouseEventHandler(textbox_MouseDown);
textbox.MouseMove += new MouseEventHandler(textbox_MouseMove);
textbox.MouseUp += new MouseEventHandler(textbox_MouseUp);
textbox.ContextMenuStrip = contextMenuStrip1;
this.Controls.Add(textbox);
}
}
我搜索了一些信息,比如使用XMLSerialize / application设置但它没有为我提供任何示例如何使用XMLSerialize添加动态按钮。请帮忙..