System.Windows.Forms.ListBox.GetSelected C# (CSharp) Method

GetSelected() public method

public GetSelected ( int index ) : bool
index int
return bool
		public bool GetSelected (int index)
		{
			if (index < 0 || index >= Items.Count)
				throw new ArgumentOutOfRangeException ("Index of out range");

			return SelectedIndices.Contains (index);
		}

Usage Example

Example #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            /*if ( listBox1.SelectedIndex > -1 )
             * MessageBox.Show("You chose: " + listBox1.SelectedItem.ToString());
             * ListBox lbi  = ((sender as ListBox).SelectedItem as ListBoxItem);
             * tb.Text = "   You selected " + lbi.Content.ToString() + ".";
             */

            if (listBox1.SelectedIndex == 0)
            {
                this.timeIntervalBetweenBars = 5;
            }
            else if (listBox1.GetSelected(1))
            {
                this.timeIntervalBetweenBars = 10;
            }
            else if (listBox1.GetSelected(2))
            {
                this.timeIntervalBetweenBars = 20;
            }



            this.Close();
        }
All Usage Examples Of System.Windows.Forms.ListBox::GetSelected