コード例 #1
0
        private void BindSounds()
        {
            if (_soundFactory == null)
            {
                comboBox1.DataSource = null;
                return;
            }

            int length = _soundFactory.GetLength <Sound>();

            List <ListItem <Sound> > sounds = new List <ListItem <Sound> >();

            for (int i = 0; i < length; i++)
            {
                var sound = _soundFactory.GetSound <Sound>(i);

                if (sound == null)
                {
                    continue;
                }

                var listItem = new ListItem <Sound>()
                {
                    Value       = sound,
                    DisplayName = sound.Name
                };

                sounds.Add(listItem);
            }

            comboBox1.DataSource    = sounds;
            comboBox1.DisplayMember = "DisplayName";
            comboBox1.ValueMember   = "Value";
        }