listbox

C# Force ListBox to update elements

岁酱吖の 提交于 2019-12-01 06:07:25
I'm subclassing the standard ListBox control. I get notified of changes to any of the elements added to the list. The task is to update the text shown by the ListBox for the changing element. I'm aware that i could just remove the changed element and add it again, but this seems not preferable for obvious reasons. Unfortunately, the data-binding in ListView doesn't support regular (item) change notification events ( FooChanged / INotifyPropertyChanged ). However, if you know about the change, you can get the list to re-bind itself. Since you are subclassing, you can call: this.RefreshItems();

Tkinter Label bound to StringVar is one click behind when updating

假装没事ソ 提交于 2019-12-01 06:05:12
问题 The problem I'm running into here is that, when I click on the different file names in the Listbox , the Label changes value one click behind whatever I'm currently clicking on. What am I missing here? import Tkinter as tk class TkTest: def __init__(self, master): self.fraMain = tk.Frame(master) self.fraMain.pack() # Set up a list box containing all the paths to choose from self.lstPaths = tk.Listbox(self.fraMain) paths = [ '/path/file1', '/path/file2', '/path/file3', ] for path in paths:

ListBox item doesn't get refresh in WPF?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 05:38:48
问题 I have a listbox which has couple of items. When double clicked on each item, the user get option to edit item (text of item). Now once i update the item, my item in listbox doesn't get updated. The first window (one which has listbox) is in MainWindow.xaml file and second window is in EditTaskView.xaml(one which let's edit the items text) file. The code that displays items in lists is: Main.Windows.cs public static ObservableCollection TaskList; public void GetTask() { TaskList = new

C# - Adding Button inside ListBox

倖福魔咒の 提交于 2019-12-01 04:57:42
I'm writing an C# App (WinForm) with a ListBox having content added by the user. Now, I could have a ordinary button under the ListBox to remove items, but I would like to have the button right next to the content, thus being inside of the ListBox. Like this: Content 1 | X Content 2 | X ... Content 5 | X The problem is that I lack experience in .NET so I have no clue on how this would be possible with all the automated controls going on. I've googled it, but came up with no meaningful results. Any hints, clues or snippets for achieving this are welcome! :) Instead of ListBox you can use

How to use IsKeyboardFocusWithin and IsSelected together?

瘦欲@ 提交于 2019-12-01 04:42:55
I have a style defined for my ListBoxItems with a trigger to set a background color when IsSelected is True: <Style x:Key="StepItemStyle" TargetType="{x:Type ListBoxItem}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border Name="Border" Padding="0" SnapsToDevicePixels="true"> <ContentPresenter /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="Border" Property="Background" Value="

How can I find listbox item index with item value?

冷暖自知 提交于 2019-12-01 04:38:55
my MessageBox.Show(listbox.Items[0].ToString()); is "abber" how can I find listbox item index 0 with "abber"? With listbox.Items.IndexOf("abber") That is: int curIndex = listbox.Items.IndexOf("abber"); if(curIndex >= 0) { MessageBox.Show(listbox.Items[curIndex].ToString()); } int index = listBox1.Items.IndexOf("Specify string here"); 来源: https://stackoverflow.com/questions/17611537/how-can-i-find-listbox-item-index-with-item-value

How to remove multiple selected items in ListBox?

家住魔仙堡 提交于 2019-12-01 04:31:34
My windows form contains two listboxes. Listbox1 contains some items in it and listbox2 is empty. When I press a button on the form, then multiple selected items from listbox1 should be removed from Listbox1 and copied to Listbox2. I tried with foreach loop on listbox1.SelectedItems but it removes only 1 item from list. Anyone has solution or code for this? You could do all in a single loop. You should use a simple for and loop backwards on SelectedIndices: private void button1_Click(object sender, EventArgs e) { for(int x = listBox1.SelectedIndices.Count - 1; x>= 0; x--) { int idx = listBox1

How To Disable Selected Item In List Box

送分小仙女□ 提交于 2019-12-01 04:23:46
I have a ListBox in my WinForms application and I want to disable some items on that list, for example if I right click on an item , it gets disabled and if I left click on a disabled item it should be enabled. How can I do this? Thanks very much ali.alikhani I found a way. We must create a custom ListBox Control to do this. :) With it, you can enable or disable items with item index. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Globalization; using System

How can I change the text of Listbox item?

心已入冬 提交于 2019-12-01 04:20:57
I have a Listbox full of items, and I need to change an item's text. Using item configure I can only find out how to change colors. How can I change the item text on a Tkinter Listbox ? To change the text you will have to delete and re-add an item at the proper index. Here is a contrived example that continuously updates the second item in the listbox: import Tkinter as tk import time class Example(tk.Frame): def __init__(self, parent): tk.Frame.__init__(self, parent) self.lb = tk.Listbox(self) self.lb.pack(fill="both", expand=True) self.lb.insert("end", "item 1","the current time", "item 3")

How to get selected value in multicolumn listbox

杀马特。学长 韩版系。学妹 提交于 2019-12-01 04:20:35
问题 I have a multicolumn listbox in my userform and I would like to get all the values of the elements which are in the selected row in the listbox. Here is my userform: Just like in the photo, I want to select one line then I will click button Associer and I could get the information of this row. I can just get the first column which is CAN20168301436 I want to get the information from the whole line. How can I do it? Here is my button clicked event: Private Sub CommandButton3_Click() a =