I have 2 forms connected to a database, LoadDocument
form and a Fom1
that is the primary form. In LoadDocument
I get document names out of my database, and when I close LoadDocument
I send the document id to Form1
so I can retrieve its content there.
唯一的问题是,如果在<代码>Form1上行使职能,则称作public void showContent(
本人的<代码>LoadDocument。 不能说它是因为它不是静态的,如果我把它固定下来的话,我会遇到创建<条码>的麻烦。
public partial class Form1 : Form
{
public void showTasks()
{
radioButtons = new RadioButton[numberOfTasks];
for (int i = 0; i < numberOfTasks; ++i)
{
radioButtons[i] = new RadioButton();
radioButtons[i].Text = "Task " + (i+1);
radioButtons[i].Location = new System.Drawing.Point(
10, 10 + i * 20);
groupBox1.Controls.Add(radioButtons[i]);
radioButtons[i].Click += new EventHandler(this.radioButtons_Click);
}
}
}
Is there any way I can call this function from LoadDocument
without making it static? Do I have to make LoadDocument
dynamic, and in that case how?
EDIT:我猜测这一法典将非常相关:
private LoadDocument m_form1;
private bool m_underConstruction = false;
private void ShowLoadDocument()
{
if (m_underConstruction)
{
// We re about to show it anyway
return;
}
m_underConstruction = true;
try
{
if (m_form1 == null)
{
m_form1 = new LoadDocument();
// m_form1.FormClosed += new FormClosedEventHandler(m_form1_FormClosed);
m_form1.Show();
}
}
finally
{
m_underConstruction = false;
}
m_form1.BringToFront();
m_form1.Activate();
}