Henry

Henry

  • NA
  • 5
  • 3.8k

Picture Viewer Application C# Help

Oct 31 2013 4:16 PM
Hey all

Can anyone help me with this piece of C# code, I'm trying to create a simple image viewer application.

So far I can only get the user to be able to select the directory he wants to view images in and have its location appear in a textbox
I'm unable to have the images available be listed in the list box and the image when selected from the listbox to be displayed in the picturebox

I'm also unable to use the Dim command for my array myimages, as the command just isn't being recognized by visual studio.

Errors are appear at the following pieces of code.

pictureBox1.ImageLocation = listBox1.SelectedItem;


and

  myimages = IO.Directory.GetFiles(textBox1.Text);
            listBox1.Items.AddRange(myimages);


Any help would be greatly appreciated as I'm fairly new to C#

Thanks

My whole code so far is,


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Picture_Viewer_Application_Q3
{
    public partial class Form1 : Form
    {
        public Form1()
          
        {
            InitializeComponent();

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            pictureBox1.ImageLocation = listBox1.SelectedItem;
           
           

        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            
            FolderBrowserDialog1.ShowDialog();
            textBox1.Text = FolderBrowserDialog1.SelectedPath;
            myimages = IO.Directory.GetFiles(textBox1.Text);
            listBox1.Items.AddRange(myimages);

           

        }

     
       

    }
}

Answers (2)