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;
using System.Collections;

namespace カブラウザもどき
{
    public partial class ParentNodeList : Form
    {
        public int resTnIndex = 0;
        Hashtable kv =  new Hashtable();

        public ParentNodeList()
        {
            InitializeComponent();
        }

        public void Show(IWin32Window owner, Hashtable folders)
        {
            //for ( int i=0; i< folders.Count; i++)
            kv = folders;
            foreach ( int i in folders.Keys )
            {   
                this.listBox1.Items.Add(folders[i]);
            }
            MessageBox.Show("銘柄コードの格納先を選択してください");
            this.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool selected = false;
            try
            {
                string result = this.listBox1.SelectedItem.ToString();
                DialogResult dr = new DialogResult();
                foreach (int i in kv.Keys)
                {
                    if ((string)kv[i] == result)
                    {
                        resTnIndex = i;
                        selected = true;
                        break;
                    }
                }
                if (!selected)
                {
                    MessageBox.Show("親になるフォルダを選択してください");
                }
                else
                {
                    this.Dispose();
                }
            }
            catch (NullReferenceException ee)
            {
                MessageBox.Show("親になるフォルダを選択してください");
                return;
            }
        }
    }
}
