listbox

Set a border around selecteditem in listbox WPF

荒凉一梦 提交于 2019-12-07 06:24:06
问题 How do i set a style on the listbox to get a border around the selected item ? 回答1: The easiest way is to add a Trigger for IsSelected in the ItemContainerStyle for the ListBox <ListBox ...> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="BorderBrush" Value="Red"/> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="BorderThickness" Value="1"/> </Trigger> </Style.Triggers> </Style> </ListBox.ItemContainerStyle> <!--...--> </ListBox>

Minimizing memory consumption listbox of images (WPF)

不羁的心 提交于 2019-12-07 04:59:08
问题 I have listbox which bind to ObservableCollection and take filename to display images My xaml is: <Window x:Class="ThumbnailsView.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="578" WindowStartupLocation="CenterScreen"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="55"/> </Grid.RowDefinitions> <ListBox Grid.Row="0" x:Name="ImageListbox"

Getting ValueMember from selected item in a ListBox with C#

依然范特西╮ 提交于 2019-12-07 03:30:30
问题 I'm trying to get all the selected items ValueMember from a ListBox with C#. For ex.: I've a list like this: ID | Name and Lastname ---------------------- 1 | John Something 2 | Peter Something2 3 | Mary Smith This structure is part of my ListBox. I've builded this listbox with this code: private void fill_people_listBox() { this.listBoxPeople.DataSource = db.query("SELECT ...."); this.listBoxPeople.DisplayMember = "people_name_last"; this.listBoxPeople.ValueMember = "people_id"; } The

Double click event on option of listbox not firing in IE

岁酱吖の 提交于 2019-12-07 03:16:42
问题 I want to attach an event to the option tags in a list box so that when I click one of them, it moves to another list box. I have this code: $('#' + opts.leftListId + ' > option').live('dblclick', function () { // Move the object }); Works fine in Firefox, but in IE the event is not fired at all. I can't use double click on the select node, because I need to move only the one that was clicked on. Any ideas? 回答1: Try this instead: $('#' + opts.leftListId).find('option').each(function(){ $(this

ListBox not getting selected items

自闭症网瘾萝莉.ら 提交于 2019-12-07 02:54:55
问题 I have a ListBox which I am adding ListItems to in a codebehind. The problem I'm having is the ListBox is not seeing the selected items. I have the ListBox being populated dynamically depending on what the user selects from a DropDownList, so the DropDownList has AutoPostBack set to true. I think this is somehow causing the problem. My SelectedIndexChanged method, which is used whenever an item in the DropDownList is selected, calls a method called PopulateListBox . Here's what those methods

Default to and select first item in Tkinter listbox

我们两清 提交于 2019-12-07 02:47:12
问题 I want to automatically select the first item in the listbox. By selecting the first item, I don't mean simply defaulting to the first item or setting focus on it. I've already achieved that by doing self.listbox.select_set(0) . I want the default item also selected . In other words, when I run my code below, I want print(value) to print the value of the default selection. If Asia is chosen from the optionmenu, Japan should automatically print to the console. If Africa, Nigeria should print

How to remove the small of padding around the ListBoxItem?

只愿长相守 提交于 2019-12-07 01:57:11
问题 I'm styling a listBox. i'm trying to clear the margins, so I realized which it, I set the padding of the style to 0 (left padding). But I can still seeing some margin in it, and I need to have no margin in it? Does you know which would be the problem? <ListBox ItemsSource="{Binding Partitions}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <Canvas /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Padding" Value="0"/>

Get a List of the Selected Values in a ListBox

偶尔善良 提交于 2019-12-07 01:37:11
问题 There's already a question with a ton of votes for getting the selected value from a dropdown using jQuery here. That answer almost works for a listbox, but if multiple values are selected, the result is a single string with all the values concatenated. This is not useful. I need a collection (list, array, whatever) of the text values for each selected option. At the moment I'm thinking I'll use most of the answer from that other question, but without the .text() at the end, and then iterate

c# - fast ListBox data update

北城余情 提交于 2019-12-06 20:23:24
I want to display in about 20 lines some text data. Every line can be longer than the size of the form is. In this case the rest of the line should be cut away. I don't want to have any h or v scroll bar. Since the ListBox control can deal with my requirements I tried to use it. Everything is working fine but if I have a heavy disk load it can happen that the control begins to flicker and I don't think this has to be. I am updating the data once a second and I always have less then 20 lines of text data. Seems that I'm using the ListBox wrong. I have the possibility to prepare the data in an

Add multiple items to a listbox on the same line

一曲冷凌霜 提交于 2019-12-06 19:44:25
Hey guys, i figured out how to add items to a listbox one line at a time: try { if (nameTxtbox.Text == "") throw new Exception(); listBox1.Items.Add(nameTxtbox.Text); nameTxtbox.Text = ""; textBox1.Text = ""; nameTxtbox.Focus(); } catch(Exception err) { MessageBox.Show(err.Message, "Enter something into the txtbox", MessageBoxButtons.OK, MessageBoxIcon.Error); } But I wont to be able to add multiple items to the same line. Like have first_name | last_name | DoB all on the same line. When I do listBox1.Items.Add(last_name.Text); It adds the last name to a new line on the listbox, I need to add