GetSelected() public method

public GetSelected ( int index ) : bool
index int
return bool
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();
        }
 private void listPats_DoubleClick(object sender, System.EventArgs e)
 {
     if (listPats.SelectedIndex == -1)
     {
         return;
     }
     SelectedPatNum = listPats.GetSelected <Patient>().PatNum;
     DialogResult   = DialogResult.OK;
 }
Example #3
0
        private void lstPhotos_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int  numSelected  = lstPhotos.SelectedIndices.Count;
            bool someSelected = (numSelected > 0);

            btnMoveUp.Enabled   = (someSelected && !lstPhotos.GetSelected(0));
            btnMoveDown.Enabled = (someSelected && (!lstPhotos.GetSelected(lstPhotos.Items.Count - 1)));
            btnRemove.Enabled   = someSelected;

            btnPhotoProp.Enabled = (numSelected == 1);
        }
Example #4
0
        /// <summary>
        /// Selects or clears the selection for the specified item in a System.Windows.Forms.ListBox.
        /// </summary>
        /// <param name="lstBox">The listbox parent.</param>
        /// <param name="index">The index of the item.</param>
        /// <param name="value">The value to set to selected property.</param>
        public static void SetSelected(System.Windows.Forms.ListBox lstBox, int index, bool value)
        {
            if ((index < -1) || (index >= lstBox.Items.Count))
            {
                throw new Exception("Invalid property value");
            }

            if (lstBox.GetSelected(index) != value)
            {
                if ((value) && ((lstBox.SelectionMode == SelectionMode.MultiSimple) || (lstBox.SelectionMode == SelectionMode.MultiExtended)))
                {
                    if (selectedIndexList.ContainsKey(lstBox))
                    {
                        selectedIndexList[lstBox] = index;
                    }
                    else
                    {
                        throw new Exception("SelectedIndex property not stored for a MultiSelect ListBox, "
                                            + "please add a ListBoxHelper to the form and set the property SelectionMode again");
                    }
                }

                lstBox.SetSelected(index, value);
            }
        }
Example #5
0
        private void btnTBLAdd_Click(object sender, System.EventArgs e)
        {
            int ncnt = 0;

            for (int i = lstTBL.Items.Count - 1; i >= 0; i--)
            {
                if (lstTBL.GetSelected(i))
                {
                    bool   isExist = false;
                    string s       = sfromdb + " . " + lstTBL.Items[i].ToString();
                    for (int j = 0; j < lstDBTBL.Items.Count; j++)
                    {
                        if (lstDBTBL.Items[j].ToString().Equals(s))
                        {
                            isExist = true;
                            break;
                        }
                    }
                    if (!isExist)
                    {
                        lstDBTBL.Items.Add(s);
                        ncnt++;
                    }
                }
            }
            frmMain.labStatus.Text = "added item:" + ncnt;
        }
Example #6
0
        private void btnDBDel_Click(object sender, System.EventArgs e)
        {
            int ncnt = 0;

            for (int i = lstDBTBL.Items.Count - 1; i >= 0; i--)
            {
                if (lstDBTBL.GetSelected(i))
                {
                    lstDBTBL.Items.RemoveAt(i);
                    ncnt++;
                }
            }
            frmMain.labStatus.Text = "removed item:" + ncnt;
        }
Example #7
0
 private void InvertMySelection()
 {
     // Loop through all items the ListBox.
     for (int x = 0; x < listBox1.Items.Count; x++)
     {
         // Determine if the item is selected.
         if (listBox1.GetSelected(x) == true)
         {
             // Deselect all items that are selected.
             listBox1.SetSelected(x, false);
         }
         else
         {
             // Select all items that are not selected.
             listBox1.SetSelected(x, true);
         }
     }
     // Force the ListBox to scroll back to the top of the list.
     listBox1.TopIndex = 0;
 }
Example #8
0
 public static void RemoveSelectedObjects(ListBox lst, ArrayList Arr = null)
 {
     if (lst == null) return;
     int MaxPos = 0;
     for (int k = 0; k < lst.Items.Count; k++)
     {
         if (lst.GetSelected(k))
         {
             MaxPos = k;
             lst.Items.RemoveAt(k);
             if (Arr != null)
                 Arr.RemoveAt(k);
             k--;
         }
     }
     if (lst.Items.Count > 0)
         if (MaxPos < lst.Items.Count)
             lst.SetSelected(MaxPos, true);
         else
             lst.SetSelected(lst.Items.Count - 1, true);
 }
        private void playButton_Click(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;
            uint        handle = 0;

            int selectedplugin = 0;

            /*
             *  Get the output plugin that was selected
             */
            for (int count = 0; count < outputList.Items.Count; count++)
            {
                if (outputList.GetSelected(count))
                {
                    selectedplugin = count;
                    break;
                }
            }

            /*
             *  Initialise system and play sound
             */
            result = system.getPluginHandle(FMOD.PLUGINTYPE.OUTPUT, selectedplugin, ref handle);
            ERRCHECK(result);

            result = system.setOutputByPlugin(handle);
            ERRCHECK(result);

            result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null);
            ERRCHECK(result);

            result = system.createSound("../../../examples/media/wave.mp3", (FMOD.MODE.SOFTWARE | FMOD.MODE.CREATESTREAM), ref sound);
            ERRCHECK(result);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
            ERRCHECK(result);
        }
        private bool valueChecked(Value value, ListBox ckdListBox)
        {
            bool retVal = false;

            for (int i = 0; i < ckdListBox.Items.Count; i++)
            {
                string val = value.getValue() + "-" + value.getDescription();
                if ((val.Equals(ckdListBox.Items[i])) & ckdListBox.GetSelected(i))
                {
                    retVal = true;
                    break;
                }
            }
            return retVal;
        }
Example #11
0
 /// <summary>
 ///  Returns a value indicating whether the specified item is selected.
 /// </summary>
 /// <param name="lstBox">The listbox to test.</param>
 /// <param name="index">The index of the item to query if it is selected.</param>
 /// <returns>True if the item is selected.</returns>
 public static bool GetSelected(System.Windows.Forms.ListBox lstBox, int index)
 {
     return(lstBox.GetSelected(index));
 }
Example #12
0
        private void ListBoxSelectedItemsRemove(ListBox listBox)
        {
            if (listBox.SelectedItems.Count == 0)
            {
                return;
            }

            if (MessageBox.Show("确定移除选中目录?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            for (int index = listBox.Items.Count - 1; index >= 0; index--)
            {
                FolderInfo folderInfo = listBox.Items[index] as FolderInfo;
                if (listBox.GetSelected(index) && !folderInfo.IsRunning)
                {
                    listBox.Items.RemoveAt(index);
                }
            }
        }
Example #13
0
 //反选
 private void unSelectAll(ListBox ListBox)
 {
     bool b;
                 for (int i = 0; i < ListBox.Items.Count; i++)
                 {
                         b = !ListBox.GetSelected(i);
                         ListBox.SetSelected(i, b);
                 }
 }
Example #14
0
        private void MoveListboxItemsFromTo(ListBox lbFrom, ListBox lbTo)
        {
            lbFrom.BeginUpdate();
            lbTo.BeginUpdate();
            try
            {
                for (int i = lbFrom.Items.Count - 1; i > -1; i--)
                {
                    if (lbFrom.GetSelected(i) == true)
                    {
                        lbTo.Items.Add(lbFrom.Items[i]);
                        lbFrom.Items.Remove(lbFrom.Items[i]);

                    }
                }
            }
            finally
            {
                lbTo.EndUpdate();
                lbFrom.EndUpdate();
                cbSelectiTunes.Checked = false;
                cbSelectConvert.Checked = false;
            }
        }