Тема: Windows form C++/CLI ListBox
Переписую приклад програми і все зробив як написано в книжці
https://books.google.com.ua/books?id=xk … mp;f=false
100 сторінка
#pragma once
namespace Project4 {
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    /// <summary>
    /// Сводка для MyForm9
    /// </summary>
    public ref class MyForm9 : public System::Windows::Forms::Form
    {
    public:
        MyForm9(void)
        {
            InitializeComponent();
            listBox1->Sorted = true;
            
            // получить имя каталога "Мои рисунки"
            DirectoryInfo^ di; // каталог
            di = gcnew DirectoryInfo(Environment::GetFolderPath(
                Environment::SpecialFolder::MyPictures)); 
            aPath = di->FullName;
            label1->Text = aPath;
            FillListBox(aPath);
            //
            //TODO: добавьте код конструктора
            //
        }
    private:  String^ aPath;    // путь к файлам картинок 
    private:  System::Boolean FillListBox(String^ aPath) {
        // информация о каталоге
        DirectoryInfo^ di = gcnew DirectoryInfo(aPath); 
      // информация о файлах
        
        array<FileInfo^> ^fi = di->GetFiles("*.jpg"); 
      // очистить список listBox1
        listBox1->Items->Clear(); 
      // Добавляем в listBox1 имена jpg-файлов,
      // содержащихся в каталоге aPath
        for each (FileInfo^ fc in fi)
        { 
            listBox1->Items->Add(fc->Name);
        } 
        label1->Text = aPath;
        if (fi->Length == 0) return false;   else {
            // выбираем первый файл из полученного списка
            listBox1->SelectedIndex = 0;
            return true;
        }
    } 
      // щелчок на кнопке Папка
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm9()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::ListBox^  listBox1;
    private:  String^ aPath;    // путь к файлам картинок 
    protected:
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::PictureBox^  pictureBox1;
    private: System::Windows::Forms::Label^  label1;
    private:
        /// <summary>
        /// Обязательная переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Требуемый метод для поддержки конструктора — не изменяйте 
        /// содержимое этого метода с помощью редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            this->listBox1 = (gcnew System::Windows::Forms::ListBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->BeginInit();
            this->SuspendLayout();
            // 
            // listBox1
            // 
            this->listBox1->FormattingEnabled = true;
            this->listBox1->Location = System::Drawing::Point(49, 40);
            this->listBox1->Name = L"listBox1";
            this->listBox1->Size = System::Drawing::Size(120, 264);
            this->listBox1->TabIndex = 0;
            this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &MyForm9::listBox1_SelectedIndexChanged);
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(49, 340);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 1;
            this->button1->Text = L"Папка...";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm9::button1_Click);
            // 
            // pictureBox1
            // 
            this->pictureBox1->Location = System::Drawing::Point(203, 40);
            this->pictureBox1->Name = L"pictureBox1";
            this->pictureBox1->Size = System::Drawing::Size(489, 323);
            this->pictureBox1->TabIndex = 2;
            this->pictureBox1->TabStop = false;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(49, 13);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(35, 13);
            this->label1->TabIndex = 3;
            this->label1->Text = L"label1";
            // 
            // MyForm9
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(718, 502);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->pictureBox1);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->listBox1);
            this->Name = L"MyForm9";
            this->Text = L"MyForm9";
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->pictureBox1))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();
        }
#pragma endregion
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
        FolderBrowserDialog^ fb = gcnew FolderBrowserDialog();
        fb->Description = "Выберите папку,\n" + "в которой находятся иллюстрации";
        fb->ShowNewFolderButton = false;
        fb->SelectedPath = aPath;
        // Отобразить окно Обзор папок и проверить,
        // щелчком на какой кнопке пользователь закрыл его
        if (fb->ShowDialog() == System::Windows::Forms::DialogResult::OK)
        {     
            // пользователь выбрал каталог и щелкнул на кнопке OK
            aPath = fb->SelectedPath;
            label1->Text = aPath; 
        if (!FillListBox(fb->SelectedPath))
            // в каталоге нет файлов иллюстраций
            pictureBox1->Image = nullptr;
        }
    }
private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
    pictureBox1->Visible = false;
    // загружаем изображение в pictureBox1
    pictureBox1->Image = gcnew Bitmap(aPath + "\\" +
        listBox1->SelectedItem->ToString()); 
    if ((pictureBox1->Image->Width > pictureBox1->Size.Width) || (pictureBox1->Image->Height > pictureBox1->Size.Height))
    {
        // масштабируем
        pictureBox1->SizeMode = PictureBoxSizeMode::Zoom;
    }   else
    {
        // масштабировать не надо
        pictureBox1->SizeMode = PictureBoxSizeMode::CenterImage;
    }   pictureBox1->Visible = true; 
}
};
}