Tagプロパティを使用して、画像の説明情報を保持できるはずです。
オン コンテキストを識別するには、イベントPictureBoxを利用できます。MouseEnter基本的にクラスレベルのPictureBox変数を定義します(PictureBoxOnContext)。
MouseEnter次に、イベント ハンドラーをインスタンスに追加し、を aPictureBoxにキャストして変数に割り当てることができます。senderPictureBoxPictureBoxOnContext
を右クリックするとPictureBox、MouseEnterすでにトリガーされており、関連PictureBoxする変数が選択されていPictureBoxOnContextます。
次に、[説明の追加] コンテキスト メニューをクリックして、確認PictureBoxOnContext != nullし、これをプレビュー フォームに渡すことができます。
(残りは理解できるはずです。おそらくデリゲートを使用して情報を親フォームに返します)
private PictureBox PictureBoxOnContext;
private void AddPicture_Click(object sender, EventArgs e)
{
PictureBox picBox = new PictureBox();
//Your code logic to add PictureBox to FlowLayout
picBox.MouseEnter += new EventHandler(PictueBox_MouseEnter);
}
void PictueBox_MouseEnter(object sender, EventArgs e)
{
PictureBoxOnContext = (PictureBox)sender;
}
private void AddDescriptionToolStripMenuItem_Click(object sender, EventArgs e)
{
if (PictureBoxOnContext != null)
{
//Pass this PictureBoxOnContext to your preview window/ your opearations
PictureBoxOnContext = null;
}
}