c# - Search Object with it's member and delete it in a list -


I have a combo box that shows the name of the object. The objects are added to the list.

  Private list & lt; Tools & gt; Toollist = New List & lt; Tools & gt; (); Private Zero Button Ad_COCAL (Object Sender, Routing Avenger, ARGS E) {InputIdOg = InputDialog; Input.ShowDialog (); InputNewTool = input.enteredTxt; If (inputNewTool! = Null) {System.Windows.Forms.MessageBox.Show ("Tools directory selected"); Dlg.DefaultExt = ".exe"; Dlg.Filter = "Application (.exe) | * .exe"; If (dlg.ShowDialog () == System.Windows.Forms.DialogResult.OK) {Tools Tools = New Tools (); ToolName = inputNewTool; Tool.pat = dlg.FileName; ToolList.Add (tool); ComboBoxTools.Items.Add (tool.Name); }}}   

Now I want to with a remove button which has not only removed the name of the object from the combo box. It is necessary that the object with this name must be removed from the list.

  Private Zero Button RemovalClick (Object Sender, RoutedEventArgs e) {int position = 0; (Int i = 0; i & lt; comboBoxTools.Items.Count; i ++) {status = comboBoxTools.SelectedIndex; RemoveTool = comboBoxTools.Items [position] .ostring (); } If (position! = -1) {for (int i = toollist.count - 1; i> = 0; - i) {if (position?) {ToolList.RemoveAt (i); }} // foreach (Tools T in tool list) // {//} comboBoxTools.Items.RemoveAt (status); } And {System.Windows.Forms.MessageBox.Show ("no items selected"); }}   

I have no clue about how to edit it may be realized: can it be that the combo box does not provide datasource or displaymember? What do I have to do to get involved so that I can use them?

I think you can see a ObservableCollection & LT; StatisticsItem & gt; equipment;

Constructor

Your button is to be added:

  Private Zero ButtonAdditionalCollect (Object Sender, Routing and ARAGS E) {InputIdog input = New inputDialog (); Input.ShowDialog (); InputNewTool = input.enteredTxt; If (inputNewTool! = Null) {System.Windows.Forms.MessageBox.Show ("Tools directory selected"); Dlg.DefaultExt = ".exe"; Dlg.Filter = "Application (.exe) | * .exe"; If (dlg.ShowDialog () == System.Windows.Forms.DialogResult.OK) {Tools Tools = New Tools (); ToolName = inputNewTool; Tool.pat = dlg.FileName; ToolList.Add (tool); Tools.add (tool)}}   

will automatically update your combo box and the deleted button:

  Private Zero button. Remove_Click (Object Sender, RoutedEventArgs E) {If (combobox.selected! = Faucet) Tools Revoke (Tool) Kamboox Selected item); Other systems Windows .form. Messagebox Show ("no items selected"); }    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -