listbox

Getting ValueMember from selected item in a ListBox with C#

寵の児 提交于 2019-12-05 08:20:57
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 ListBox is successfully populated. When the user wants to save the changes I've to loop throught this list to

How to remove the small of padding around the ListBoxItem?

北城以北 提交于 2019-12-05 08:20:25
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"/> <Setter Property="Canvas.Top"> ... </Setter> </Style> </ListBox.ItemContainerStyle> I mean, I can see an

ListBox not getting selected items

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:06:41
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 looks like: protected void SelectedIndexChanged(object sender, EventArgs e) { string typeStr = type

Default to and select first item in Tkinter listbox

与世无争的帅哥 提交于 2019-12-05 07:53:43
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 and Germany for Europe. Any suggestion on how I can achieve this? Thanks. from tkinter import * from

wpf Datagrid columns width fail in ListBox

我的未来我决定 提交于 2019-12-05 07:49:40
I have a ListBox that contains items derived from UserControl. The concrete UserControl contains (among others) a DataGrid. Basically I cannot change the concrete UserControl (changes only for testing purpose; its kind of third party). The DataGrid column width of all columns gets broken as soon as one column width is set to "*", which is required to fill the complete space. I can reproduce it with a simplified example (w/o UserControl). So if I add a DataGrid as ListBoxItem, specifying a column width of "*" breaks the column width. BTW, the columns also cannot be resized by the user anymore.

WPF - How do I get an object that is bound to a ListBoxItem back

穿精又带淫゛_ 提交于 2019-12-05 07:36:41
here is what I would like to do. I get a List of objects from a database and bind this list to a ListBox Control. The ListBoxItems consist of a textbox and a button. Here is what I came up with. Up to this point it works as intended. The object has a number of Properties like ID, Name. If I click on the button in the ListBoxItem the Item should be erased from the ListBox and also from the database... <ListBox x:Name="taglistBox"> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="HorizontalAlignment" Value="Stretch"/> <Setter Property="Template"> <Setter

Double click event on option of listbox not firing in IE

浪尽此生 提交于 2019-12-05 07:15:46
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? Try this instead: $('#' + opts.leftListId).find('option').each(function(){ $(this).live('dblclick', function () { // Move the object }); }); Update (10:21 GMT) Try taking out the live: $('#

Minimizing memory consumption listbox of images (WPF)

拜拜、爱过 提交于 2019-12-05 06:04:10
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" ItemsSource="{Binding}" Background="AliceBlue" ScrollViewer.HorizontalScrollBarVisibility="Disabled">

Switching ListBox ItemTemplate based on both item type and view option

不打扰是莪最后的温柔 提交于 2019-12-05 05:56:08
问题 I'm currently implementing a listbox in WPF that will have 2 alternative layouts for its items: So far, I've done this using a DataTrigger to switch the ItemTemplate for the ListBox and it's working well: <ListBox ItemsSource="{Binding Runs}" SelectedItem="{Binding SelectedRun}"> <ListBox.Style> <Style TargetType="ListBox"> <Setter Property="ItemTemplate" Value="{StaticResource tileTemplate}"/> <Style.Triggers> <DataTrigger Binding="{Binding ShowRunsAsIcons}" Value="True"> <Setter Property=

wpf listbox and datatemplate with grid inside

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:21:17
问题 I have a following question. I want to have ListBox with DataTemplate as Grid . This grid has 2 two columns. I want to set first column width to 3* and another to * . How to do this? I will copy my code. <ListBox x:Name="commandListbox" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="3*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Grid