I can create a linklabels on the fly but can't seem to pass what I want to run when linklabel clicked as it depends on which linklabel was clicked
OBJECTIVE: create a link to a video for each video file in a folder.
CODE THAT DOESN'T WORK:
OBJECTIVE: create a link to a video for each video file in a folder.
CODE THAT DOESN'T WORK:
Code:
// Set the directory to the sample picture directory.
System.IO.DirectoryInfo dirInfo =
new System.IO.DirectoryInfo(
"c:\\Documents and Settings\\Delora\\Desktop");
// Get the .jpg files from the directory
System.IO.FileInfo[] files = dirInfo.GetFiles("*.avi");
// Add each file name and full name including path
// to the ListView.
i=5;
if (files != null)
foreach ( System.IO.FileInfo file in files )
{
linkLabel = new LinkLabel();
linkLabel.Size = new Size( 180, 20 );
linkLabel.Location = new Point(10,i);
linkLabel.Text = file.Name;
linkLabel.Links.Add(0,file.Name.Length,dirInfo.Name + file.FullName);
linkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(this.OnClickVid(dirInfo.Name + file.FullName));
this.Controls.Add(linkLabel);
i=i+20;
}
}
public void OnClickVid (string filename)
{
linkLabel.LinkVisited = true;
MessageBox.Show(filename);
//System.Diagnostics.Process.Start( filename );
}