我正在开发一个生成 PDF 文件的程序。在最终生成文件之前,我想让用户选择编辑文件的一部分(即将创建的图形的标题)。当用户单击按钮导出 PDF 时,我希望它以新形式显示。这是我正在尝试做的事情的大纲......
private void button4_Click(object sender, EventArgs e) // Test PDF Code!
{
Form2 NewPDF = new Form2(chart3.Titles[chart3.Titles.IndexOf("Header")].Text.ToString().Substring(0, chart3.Titles[chart3.Titles.IndexOf("Header")].Text.ToString().Length - 4));
NewPDF.Show();
if (NewPDF.Selected == true)
{
// Create PDF, open save file dialog, etc
}
}
这是单击此按钮打开的表单...
public partial class Form2 : Form
{
public bool Selected
{
get;
set;
}
public String GraphName
{
get;
set;
}
public Form2(String FileName)
{
InitializeComponent();
textBox1.Text = FileName;
GraphName = FileName;
Selected = false;
}
public void button1_Click(object sender, EventArgs e)
{
GraphName = textBox1.Text;
this.Selected = true; // After the button is selected I want the code written above to continue execution, however it does not!
}
}
截至目前,当我点击Form2中的按钮时,没有任何反应,两个Form之间的通信有一些我不理解的东西!