listbox

How to fit Tkinter listbox to contents

﹥>﹥吖頭↗ 提交于 2019-11-29 07:29:43
I am writing a program to run batch files for various servers and so far everything is going fine. I mean the programs works and uses a simple GUI and all is well. Apart from when I give it a slightly longer name to display in the listbox it clips the end off. The code that Tkinter uses is below. master = tk.Tk() listbox = tk.Listbox(master, selectmode=tk.SINGLE) keys = serverDict.keys() for key in sorted(keys): listbox.insert(tk.END, key) button = tk.Button(master, text="Execute", command=execute) listbox.pack() button.pack() tk.mainloop() So basically it all works perfectly fine, I'm not

SelectedItem set to first item with CollectionViewSource

自古美人都是妖i 提交于 2019-11-29 07:10:31
I have a view databound through mvvm light to a viewmodel in my WP7 project. The view contains a Listbox with following settings: <ListBox x:Name="StationList" ItemsSource="{Binding StationList}" SelectedItem="{Binding SelectedStation, Mode=TwoWay}" > The StationList is a ObservableCollection. Now when the view gets loaded, everything looks great! The list is shown and NO item is selected! But when I change the XAML to: <ListBox x:Name="StationList" ItemsSource="{Binding Source={StaticResource StationListSorted}}" SelectedItem="{Binding SelectedStation, Mode=TwoWay}" > With the

Way to color parts of the Listbox/ListView line in C# WinForms?

吃可爱长大的小学妹 提交于 2019-11-29 06:52:53
Is there a way to color parts of ListBox Items (not only whole line)? For example listbox item consists of 5 words and only one is colored or 3 of 5. Is there a way to do the same with ListView? (I know that ListView can be colored per column but i would like to have multiple colors in one column). I am interested in only free solutions, and preferred that they are not heavy to implement or change current usage (the least effort to introduce colored ListBox in place of normal one the better). With regards, MadBoy This article tells how to use DrawItem of a ListBox with DrawMode set to one of

Setting focus on a ListBox item breaks keyboard navigation

淺唱寂寞╮ 提交于 2019-11-29 06:39:29
After selecting ListBox item programmatically it is needed to press down\up key two times to move the selection. Any suggestions? View: <ListBox Name="lbActions" Canvas.Left="10" Canvas.Top="10" Width="260" Height="180"> <ListBoxItem Name="Open" IsSelected="true" Content="Open"></ListBoxItem> <ListBoxItem Name="Enter" Content="Enter"></ListBoxItem> <ListBoxItem Name="Print" Content="Print"></ListBoxItem> </ListBox> Code: public View() { lbActions.Focus(); lbActions.SelectedIndex = 0; //not helps ((ListBoxItem) lbActions.SelectedItem).Focus(); //not helps either } Don't set the focus to the

How can I overwrite my ListBox's ItemTemplate and still keep the DisplayMemberPath?

[亡魂溺海] 提交于 2019-11-29 06:27:49
I have a generic style for a ListBox that overwrites the ItemTemplate to use RadioButtons . It works great, EXCEPT when I set a DisplayMemberPath . Then I just get the .ToString() of the item in the ListBox . I feel like I'm missing something simple here... can someone help me spot it? <Style x:Key="RadioButtonListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="BorderBrush" Value="Transparent"/> <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle" /> <Setter Property="ItemContainerStyle"> <Setter.Value> <Style TargetType="{x:Type ListBoxItem}" > <Setter Property

Databinding a ListBox with SelectionMode = Multiple

两盒软妹~` 提交于 2019-11-29 05:59:27
I have a WPF ListBox that I would like to Enable multiple selection in the ListBox , and Databind the ListBox to my view model. These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems property. When I compiled, I got an error saying that the SelectedItems property was read only and could not be set from XAML. Am I binding to the wrong control property? Is there a way to bind a multiple-selection ListBox in XAML to a view model collection property?

How to remove all ListBox items?

元气小坏坏 提交于 2019-11-29 04:54:04
问题 I created two RadioButton (Weight and Height). I will do switch between the two categories. But the they share the same ListBox Controllers (listBox1 and listBox2). Is there any good method to clear all the ListBox items simpler? I didn't find the removeAll() for ListBox. I don't like my complex multi-lines style which I posted here. private void Weight_Click(object sender, RoutedEventArgs e) { // switch between the radioButton "Weith" and "Height" // Clear all the items first listBox1.Items

How to pass listbox selecteditem as command parameter in a button?

蹲街弑〆低调 提交于 2019-11-29 04:36:11
问题 Here is my situation: <ListBox ItemsSource="{Binding Path=AvailableUsers}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Id}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Button Command="{Binding Path=Load}" CommandParameter={???? What goes here ????}/> What I want is to pass the Id that is currently selected in the ListBox. I have a viewmodel behind the scenes that essentially looks like this: public class ViewModel : DependencyObject { ICommand Load { get;

ASP:ListBox Get Selected Items - One Liner?

落爺英雄遲暮 提交于 2019-11-29 04:04:13
I am trying to get the selected items of an asp:ListBox control and put them in a comma delimited string. There has got to be a simpler way of doing this then: foreach (ListItem listItem in lbAppGroup.Items) { if (listItem.Selected == true) { Trace.Warn("Selected Item", listItem.Value); } } Is there a way to get this into one line? like my pseudo code here: string values = myListBox.SelectedItems; I am using ASP.NET and C# 3.5. Thanks for any help!! Using LINQ: string values = String.Join(", ", lbAppGroup.Items.Cast<ListItem>() .Where(i => i.Selected) .Select(i => i.Value)); I don't think

Difference between ListView and ListBox in Visual Studio

此生再无相见时 提交于 2019-11-29 03:09:05
What is the difference between "ListView" and "ListBox" in a "Windows 8" app. The ListBox is an older control primarily for compatibility with other xaml frameworks. The ListView has build-in functionality for touch etc. Use the ListView unless you have a specific need for the ListBox See here for more detail. Specific events available only for ListView : DragItemsStarting ItemClick Methods: CompleteViewChange CompeteViewChangeFrom CompleteViewChangeTo InitializeViewChange LoadMoreItemsAsync MakeVisible ScrollIntoView(Object, ScrollIntoViewAlignment) StartViewChangeFrom StartViewChangeTo