I have been working on this in my spare time, to no avail. I really could use a hand getting this to work.
I have a winform in C#. I am currently working with a listbox and a picturebox to display embedded image resources. I want to populate the listbox with just the file name, as the full path is longer than the width of the listbox can accommodate on my form.
Here is some code I was working with:
string[] x = System.IO.Directory.GetFiles(@"C:\Users\bassp\Dropbox\VS Projects\WindowsFormsApplication1\WindowsFormsApplication1\Resources\", "*.jpg");
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
foreach (string f in x)
{
string entry1 = Path.GetFullPath(f);
string entry = Path.GetFileNameWithoutExtension(f);
listBox1.DisplayMember = entry;
listBox1.ValueMember = entry1;
listBox1.Items.Add(entry);
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBox1.ImageLocation = listBox1.SelectedItem.ToString();
}
If I populate the listbox with the full path,(entry1), things work pretty smooth other than not being able to see the image name you will be selecting due to the length of the full path.
When I try to populate the listbox with (entry), just the file names appear in the listbox, which is desireable, however, the image will no longer open on selection from the listbox.
How can I get this working correctly? Help is greatly appreciated.
Patrick