listbox

List index out of bounds whilst deleting items

牧云@^-^@ 提交于 2019-12-01 08:25:41
I solved my problem but I need to know why this problem raised to me ?! I write a project that load file to listBox then delete the strings one by one, but when I delete listBox strings this exception raised to me! list index out of bounds (5) ! I type this for loop to read list box and delete strings: for i := 0 to ListBox3.Count -1 do begin ShowMessage(ListBox3.Items[i]); ListBox3.items.Delete(i); end; and my problem solved by do a little change in for-loop statement for i := ListBox3.Items.Count - 1 downto 0 do begin ShowMessage(ListBox3.Items[i]); ListBox3.items.Delete(i); end; Why the

Is there a potential way to disable user input in a <datalist>?

[亡魂溺海] 提交于 2019-12-01 07:04:31
I'm debating between using a <select> or <datalist> to display a drop-down list from which the user can select the items. One downside of the <select> tag is that it's inconsistent as it renders differently in different browsers: some browsers it displays with scroll bar, and for some it's a drop-down list. The <datalist> on the other hand seems good but I just want to know if there is any way to disable the text input where the user can type whatever they want in the text box if they don't click the down arrow button on the input field as shown: ​<form action="demo_form.asp" method="get">

Selected item in list box is null

…衆ロ難τιáo~ 提交于 2019-12-01 06:59:02
问题 I have few items in the listbox. When I select an item, I store it in a string for further use, but when I display that string value it is shown as null. Below is the code for my Invitee.aspx file: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Invitee.aspx.cs" Inherits="FinalProj2.Invitee" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">

Listbox in asp.net not getting selected items

梦想的初衷 提交于 2019-12-01 06:36:21
问题 I have multiple dropdown & listbox in my webpage. I am trying to get a list of CategoryID from a lstCatID listbox i am able to populate the listbox with category name. If i remember correctly in first attempt my code worked fine, after that i made some change then it stated to always get the first item selected x No. of time <asp:ListBox ID="lstCatID" runat="server" DataTextField="CategoryName" DataValueField="CategoryID" SelectionMode="Multiple" CssClass="lstListBox"> </asp:ListBox>

Fill WPF listbox with string array

守給你的承諾、 提交于 2019-12-01 06:35:22
Instead of adding each item one by one to the ListBox destinationList from the string array m_List like this: foreach (object name in m_List) { destinationList.Items.Add((string)name); } Is there any better way I can do it? I don't want to bind the data to the destinationList since I want to delete some entries from the ListBox later on. HTH: string[] list = new string[] { "1", "2", "3" }; ObservableCollection<string> oList; oList = new System.Collections.ObjectModel.ObservableCollection<string>(list); listBox1.DataContext = oList; Binding binding = new Binding(); listBox1.SetBinding(ListBox

i want to detect an item double click in a winforms listbox control. [how to handle click on blank area?]

霸气de小男生 提交于 2019-12-01 06:34:41
问题 well i have a listbox with some items inside. i want to detect a double click on an item. currently the method i am using have a problem that if a user double click on an empty spot the currently selected item is signaled as double clicked. Update: Please note that this question is not as easy as it seems at first. also note that Timwi answer is not correct because the [if (ListBox1.SelectedIndex == -1)] part dont get executed if there is an item selected and i clicked in an empty space i

Tkinter Label bound to StringVar is one click behind when updating

只愿长相守 提交于 2019-12-01 06:25:55
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: self.lstPaths.insert(tk.END, path) self.lstPaths.bind('<Button-1>', self.update_label) self.lstPaths.pack(

Insert whitespace between characters in listbox

穿精又带淫゛_ 提交于 2019-12-01 06:21:54
I am trying to insert items into a listbox in my asp.net C# application I concatenate some values and put whitespace in between them but it doesn't show up in the listbox. ListItem lt = new ListItem(); lt.Text = ItemName + " " + barcode + " " + price; // problem lt.Value = barcode; lstMailItems.Items.Add(lt); i even tried lt.Text = ItemName + "\t\t" + barcode + "\t\t" + price; // problem lt.Text = ItemName + "& nbsp;" + barcode + "& nbsp;" + price; // &nbsp shows up as text but that even doesn't seem to work. How can I put whitespace between these strings so that it shows up in the listbox as

List index out of bounds whilst deleting items

不问归期 提交于 2019-12-01 06:18:57
问题 I solved my problem but I need to know why this problem raised to me ?! I write a project that load file to listBox then delete the strings one by one, but when I delete listBox strings this exception raised to me! list index out of bounds (5) ! I type this for loop to read list box and delete strings: for i := 0 to ListBox3.Count -1 do begin ShowMessage(ListBox3.Items[i]); ListBox3.items.Delete(i); end; and my problem solved by do a little change in for-loop statement for i := ListBox3.Items

Items on ListBox show up as a class name

懵懂的女人 提交于 2019-12-01 06:12:56
The problem is as follows: I connected the ListBox with a list of elements of some custom class ( List<Person> persons = new List<Person>() ) using DataSource property. Of course ValueMember and DisplayMember are both assigned to appropriate properties of this class. When I first load data, everything looks ok. However, when I click on some item (i.e. 7th position, counting from 1) and then rebuild the list AND the number of elements is LESS than 7, as a result I can't see the proper texts on the list. Instead, every item shows up as a class name, preceded by the namespace. In other words,