Form1(メインフォーム)とForm2の2つのフォームがあります。Form 1 は画像ファイル、pdf 変換などを表示します。ただし、ユーザーが Zip ファイルを表示したい場合は、Form2 が呼び出され、listView で利用可能なすべての Zip ファイルのプレビューが表示されます。ユーザーが Form2 で特定の Zip ファイルを選択すると、ファイルが解凍され、画像ファイルが Form2 に送信されます。しかし、Form1 から Form2 を更新する方法がわかりません。ところで、Form2 のすべての画像が Form の変数リストに表示されるようになりました。表示されますが、フォームは更新されませんでした。
form2 コード:
private void btn_read_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.ReadArchives(Filepath); //this function creates the image files on Form1
this.Close(); //close form2
for (int index = Application.OpenForms.Count - 1; index >= 0; index--)
{
if (Application.OpenForms[index].Name == "Form1")
{
//Application.OpenForms[index].Close();//EFFECTIVE BUT CLOSES THE WHOLE APPLICATION
Application.OpenForms[index].Invalidate(); //no effect
Application.OpenForms[index].Refresh();//no effect
Application.OpenForms[index].Update();//no effect
Application.OpenForms[index].Show();//no effect
}
}
}