listbox

Removing a selection from a listbox, as well as remove it from the list that provides it

回眸只為那壹抹淺笑 提交于 2021-02-09 01:43:08
问题 How can I use the following code to delete a selection from a listbox and removing it from the list the contains it also? The selections in the listbox are dictionaries which I store in a list. .................code.............................. self.frame_verDatabase = Listbox(master, selectmode = EXTENDED) self.frame_verDatabase.bind("<<ListboxSelect>>", self.OnDouble) self.frame_verDatabase.insert(END, *Database.xoomDatabase) self.frame_verDatabase.pack() self.frame_verDatabase.config

Add and delete text to/from ListBox hosted in WinForm using C#

烂漫一生 提交于 2021-02-08 19:37:40
问题 I am working on a simple application that to add/delete string/s into an array and show that in ListBox. My code shows only the latest value that was typed into the textBox and private void Add_Click(object sender, EventArgs e) { string add = textBox1.Text; List<string> ls = new List<string>(); ls.Add(add); String[] terms = ls.ToArray(); List.Items.Clear(); foreach (var item in terms) { List.Items.Add(item); } } private void Delete_Click(object sender, EventArgs e) { } 回答1: This code makes no

Get ListBox to resize with window, but not resize with content

旧巷老猫 提交于 2021-02-08 12:24:11
问题 There must be an elegant solution to this problem, but I can't find anything online. I have a grid that has one column and row with width/height *, containing a ListBox. I have my Window SizeToContents set to WidthAndHeight to allow the window to resize to the proper size for each set of UI widgets/fonts. When I add items to the ListBox, it resizes, causing the window to grow. I want the ListBox to resize if I change the size of the window, but if I add content that is longer than the width

Search via textbox to auto-update listbox entries

隐身守侯 提交于 2021-02-08 08:52:07
问题 I would like to implement a search function in a listbox in a userform getting a better view of the many columns and unfortunately I can't find a solution. The optimal solution would be, if I could search in a textbox for any row content (up to 12 columns containing data like e.g. name, ID, position, organization, ...) and the listbox would automatically update itself showing all matching entries. In UserForm_Initialize I filled the listbox as follows: Private Sub UserForm_Initialize() With

ListBox SelectedValueChanged/SelectedIndexChanged not firing when data source changes

微笑、不失礼 提交于 2021-02-07 14:28:29
问题 I need to keep track of the selected item on a ListBox to update/disable other controls according to the currently selected value. This is the code to reproduce the issue: public partial class Form1 : Form { private readonly BindingList<string> List = new BindingList<string>(); public Form1() { InitializeComponent(); listBox1.DataSource = List; listBox1.SelectedValueChanged += (s, e) => System.Diagnostics.Debug.WriteLine("VALUE"); listBox1.SelectedIndexChanged += (s, e) => System.Diagnostics

WPF binding Listbox SelectedItem in ViewModel

南楼画角 提交于 2021-02-05 09:34:46
问题 I'm working on a WPF application. The main page is made up of a grid with 2 column and one row. on the first column i have a listbox and on the 2nd column i have a stackpanel named thePanel which i want to change on selected item of a listbox.i first implemented this in the View(mainwindow.xaml.cs) with the selectionChanged event of the Listbox and it worked. I tried to apply the MVVM so i had to do it in the viewModel. the Data Context of the mainwindow is set in its constructor and is of

Show items in listbox from database in C#

陌路散爱 提交于 2021-02-05 08:38:10
问题 I have have a database with two tables Countries and Websites . I am displaying all countrynames in listbox1 with the following statement: try { connection.Open(); using (OleDbCommand command = new OleDbCommand()) { command.Connection = connection; command.CommandText = "SELECT CountryName FROM Countries "; //whenever you want to get some data from the database using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { listBox1.Items.Add(reader["CountryName"].ToString(

wpf listbox selecteditem background colour change without changing system brush

心已入冬 提交于 2021-01-29 20:21:39
问题 I have a Listbox control that I want to remove selection highlighting from. I know the initial instinct will be to suggest overriding the system highlight brush colour but unfortunately that seems to do so for all controls, and I have an embedded combobox within the listboxitem template that I do NOT want the selected item to be transparent for. Is there a way to change the selected item highlight colour without changing the system highlight brush? 回答1: Apply the style directly to the ListBox

Excel VBA sort Listbox data if not numeric to bottom

ⅰ亾dé卋堺 提交于 2021-01-29 18:30:33
问题 I am using the below code to sot my Listbox data numerically. I use the following IF statement to check if data is numeric (some data is not): If IsNumeric(.List(i, 4)) And IsNumeric(.List(j, 4)) Then My Listbox data is sorted correctly. However because of the above IF statement the sorting process ignores non-numeric data. I need to sort the non numeric data to the bottom of the Listbox. Public Sub BubbleSort() Dim i As Long Dim j As Long Dim Temp4 As Variant, Temp3 As Variant, Temp2 As

Listbox events firing strangely

匆匆过客 提交于 2021-01-29 10:48:11
问题 I'm confused. I am basically trying to tell when the user has clicked something in the listbox, held the button, and left the listbox. Here is a somewhat dumbed down version of what I am doing: private bool itemHeld; private void listOriginal_MouseDown(object sender, MouseEventArgs e) { itemHeld = true; } private void listOriginal_MouseUp(object sender, MouseEventArgs e) { itemHeld = false; } private void listOriginal_MouseLeave(object sender, EventArgs e) { if (itemHeld) MessageBox.Show("OHH