In my win form application having 1 button ,folderbrowseDialog box, Picturebox inside the Panel.
On Button click open folderbrowsedialog for open the images folder i want to add this list images to my contextmenu at runtime i get that images path at runtime but now i am not able to get the click on that context menu to select the path the respective image is not display at picturebox in c#
I want help for this.......
Thanks
private void button1_Click(object sender, EventArgs e)
{
int iCtr = 0;
ContextMenuStrip docmenu = new System.Windows.Forms.ContextMenuStrip();
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
//MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
foreach (string imageFile in files)
{
//string imageFile = i.ToString();
//if (Image.FromFile(imageFile) != null)
//{
ToolStripMenuItem openimg = new ToolStripMenuItem();
openimg.Text = imageFile.ToString();
iCtr++;
docmenu.Items.AddRange(new ToolStripMenuItem[] { openimg });
pictureBox8.ContextMenuStrip = docmenu;
//}
}
}
}