listbox

Why does the WPF listbox change selection on mouse button down rather than button up?

旧时模样 提交于 2019-12-06 19:28:45
问题 I had never noticed this before, but the WPF ListBox seems to change its SelectedItem when the Mouse is down, but has not yet been released. As a quick example, just create a simple ListBox with several ListBoxItems, like so: <ListBox> <ListBoxItem>Hello</ListBoxItem> <ListBoxItem>World</ListBoxItem> <ListBoxItem>ListBox</ListBoxItem> <ListBoxItem>Test</ListBoxItem> </ListBox> fire up your application, press the mouse button (don't release it!) and move the mouse around. The SelectedItem will

ASP.NET Populate a listbox without a postback

岁酱吖の 提交于 2019-12-06 19:16:38
I have a simple aspx page with a textbox, linkbutton and listbox. The listbox is to be populated with values from a stored procedure in a SQL database. What I'd like to do, somehow, is to populate the listbox with those variables when the user clicks the linkbutton. Ideally, I'd like to do this WITHOUT a postback. Is there any way this can be accomplished? Thanks, Jason I mocked one up for you really quickly. <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>

ListBox with single select and also unselect on click…?

戏子无情 提交于 2019-12-06 17:25:25
问题 I need a listbox that selects on first click and un-selects on second click, so that only zero or one item is selected at any time. The select/unselect is implemented in the listbox (with SelectionMode="Single") when you hold down crtl, but unfortunately, none of my users can be expected to know that. With SelectionMode="Multiple" we have the exact functionality I want, except that you can select more than one item... More background: I want the user to first choose which installation to log

Putting two-dimensional array in listbox

≯℡__Kan透↙ 提交于 2019-12-06 16:46:29
问题 So I have this array string[,] cars = new String[2, 2] { { "VW Golf GTI", "30000" }, { "Porsche GT3", "300000" }, { "Porsche Cayenne", "80000" }, { "BMW M6", "90000" } }; And want to put everything in a listbox, and I thought this would work, but it doesn't :/ lstBoxMarket.Items.AddRange(cars); Now how do I put everything in the listbox in the format Car - Price ? 回答1: Try this: string[,] cars = new string[4, 2] { { "VW Golf GTI", "30000" }, { "Porsche GT3", "300000" }, { "Porsche Cayenne",

gtk-listbox -contents shown in middle of horizontal line, listbox does not fit window size

一世执手 提交于 2019-12-06 16:27:23
I wrote a code for listbox in gtk problems 1. the contents of listbox are shown in middle of horizontal line. I want it to be left aligned. 2. the listbox does not fit the window size 3.the list box is within a notebook tab. I want when the item in the listbox is selected some processing to be done(some function called), the current tab display is hidden and new tab is displayed with the results and a back button. When Back button is pressed it does 2 cases for 2 tabs in 1 tab- it just shows the previous content in tab 2- it does processing again and shows results in list box in original

How to count duplicate items in ListBox using Visual Basic 2008?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 16:07:03
问题 I want to count duplicate items in my ListBox. Ex. I have this in my List Box. Chocolate Mango Melon Chocolate Chocolate Strawberry Chocolate Strawberry What I want is to have this output. Chocolate - 4 Strawberry - 2 Mango - 1 Melon -1 回答1: Here's a little function I wrote real quick for you. This can be used anywhere and all you need to do is pass the ListBox object to it; it will return a string containing the item's and their count's. You can change this as well to return the Dictionary

Delete Selected File from Listbox and Folder

送分小仙女□ 提交于 2019-12-06 15:59:27
I want to Delete the Selected File from Listbox and Folder. For now it's only removing it from the Listbox. Now I want it to be removed also from the Folder. Thanks private void tDeletebtn_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) listBox1.Items.RemoveAt(listBox1.SelectedIndex); } private void TeacherForm_Load(object sender, EventArgs e) { DirectoryInfo dinfo = new DirectoryInfo(@"data\\Teachers\\"); FileInfo[] Files = dinfo.GetFiles("*.xml"); foreach (FileInfo file in Files) { listBox1.Items.Add(file.Name); } } If your listBox1.Items contains your filepath, you

How can I align strings added as listbox items?

南楼画角 提交于 2019-12-06 15:49:35
I have a listbox where I want to display a list of names and highscores from a character class. I use ListBox.Items.Add to add the following string for each character: public String stringHighscore() { return name + "\t\t\t" + score.ToString(); } The problem is that when the name exceeds a certain length, the score gets pushed to the right. The listbox looks like this (sorry, my rep doesn't allow me to post images yet): (Link to the listbox image on tinypic) I have thought this may be due to the "\t" but I am not sure. How can I solve this and properly align the scores? Would it be better if I

GWT Multiselect Dropdown Listbox

这一生的挚爱 提交于 2019-12-06 15:43:10
I'm looking to create a multi-select dropdown listbox in GWT, but I'm not sure how to go about doing so. I'd like it to be similar to this: Any suggestions? Should I take gwt ListBox code and adapt it to accept objects? Or should I forget their Listbox and try to make my own from scratch? Or should I go in a different direction completely? I'd really prefer not to include external libraries (like SmartGWT) if possible - I'm trying to stick with straight-up GWT. Please advise. Thanks! For anyone interested, I actually ended up rolling my own... It's a TextBox with an Image next to it. And each

Clear wpf listbox selection using button in control template and no codebehind

核能气质少年 提交于 2019-12-06 15:24:24
问题 I want to create a Style for a WPF ListBox that includes a Button in the ControlTemplate that the user can click on and it clears the ListBox selection. I dont want to use codebehind so that this Style can be applied to any ListBox . I have tried using EventTrigger s and Storyboard s and it has proved problematic as it only works first time and stopping the Storyboard sets the previous selection back. I know I could use a user control but I want to know if it is possible to achieve this using