combobox

Binding Combobox Using Dictionary as the Datasource

岁酱吖の 提交于 2019-12-17 15:35:26
问题 I'm using .NET 2.0 and I'm trying to bind a combobox's Datasource to a sorted dictionary. So the error I'm getting is "DataMember property 'Key' cannot be found on the Datasource". SortedDictionary<string, int> userCache = UserCache.getSortedUserValueCache(); userListComboBox.DataSource = new BindingSource(userCache, "Key"); //This line is causing the error userListComboBox.DisplayMember = "Key"; userListComboBox.ValueMember = "Value"; 回答1: SortedDictionary<string, int> userCache = new

Populating a ComboBox using C#

北城以北 提交于 2019-12-17 15:32:45
问题 I would like to populate a combobox with the following: Visible item / Item Value English / En Italian / It Spainish / Sp etc.... Any help please? Also it is possible that after populating the Combobox, to make it read only? 回答1: Define a class public class Language { public string Name { get; set; } public string Value { get; set; } } then... //Build a list var dataSource = new List<Language>(); dataSource.Add(new Language() { Name = "blah", Value = "blah" }); dataSource.Add(new Language() {

How to bind a ComboBox to generic dictionary via ObjectDataProvider

我的梦境 提交于 2019-12-17 15:30:00
问题 I want to fill a ComboBox with key/value data in code behind, I have this: XAML: <Window x:Class="TestCombo234.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TestCombo234" Title="Window1" Height="300" Width="300"> <Window.Resources> <ObjectDataProvider x:Key="Choices" ObjectType="{x:Type local:CollectionData}" MethodName="GetChoices"/> </Window.Resources> <StackPanel

Tkinter insert a Combobox inside a Treeview widget

[亡魂溺海] 提交于 2019-12-17 14:21:47
问题 For example, lets create a Treeview widget using a class as follows: class FiltersTree: def __init__(self, master, filters): self.master = master self.filters = filters self.treeFrame = Frame(self.master) self.treeFrame.pack() self._create_treeview() self._populate_root() def _create_treeview(self): self.dataCols = ['filter', 'attribute'] self.tree = ttk.Treeview(self.master, columns = self.dataCols, displaycolumns = '#all') Populate root, insert children as usual. At the end of the codeblock

How to set selected value from Combobox?

笑着哭i 提交于 2019-12-17 11:31:51
问题 I use combobox in c# windows form. I bound the item list as below: var employmentStatus = new BindingList<KeyValuePair<string, string>>(); employmentStatus.Add(new KeyValuePair<string, string>("0", "[Select Status]")); employmentStatus.Add(new KeyValuePair<string, string>("1", "Contract")); employmentStatus.Add(new KeyValuePair<string, string>("2", "Part Time")); employmentStatus.Add(new KeyValuePair<string, string>("3", "Permanent")); employmentStatus.Add(new KeyValuePair<string, string>("4"

Interaction Triggers in Style in ResourceDictionary WPF

廉价感情. 提交于 2019-12-17 10:42:21
问题 I have a ComboBox which I need to use in several places in my application, so I set most of the properties of that ComboBox in ResourceDictionary and use that as a Style where ever I need it. Style for the ComboBox is: <Style TargetType="{x:Type ComboBox}" x:Key="ComboBoxBranch"> <Setter Property="ItemsSource" Value="{Binding Branches}"></Setter> <Setter Property="DisplayMemberPath" Value="BranchName"></Setter> <Setter Property="SelectedItem" Value="{Binding SelectedBranch}"></Setter> </Style

Assigning a value to ComboBox Items

主宰稳场 提交于 2019-12-17 10:04:48
问题 I'm currently trying to make a drop box (Combobox) for currencies for a winform. Here's what I have so far: But I noticed that there is a special option for the Databound version of a drop down box. So I was wondering if it was possible to create something similar to this without resorting to do a comparison against the entire string or creating a table in a database. 回答1: List and Comboboxes can contain objects rather than simply strings. Rather than defining the contents in the Designer,

WPF: How to customize SelectionBoxItem in ComboBox

巧了我就是萌 提交于 2019-12-17 09:54:17
问题 I want to display a custom template/item as selected item in ComboBox (this item does not actually exist in the list of items and is updated differently). This does not even needs to be an item, just providing a custom view would work. How can I do this while staying within current ComboBox theme (so no ControlTemplate replacement possible)? As far as I see, all of SelectionBox* properties are not editable and internally ComboBox uses unnamed ContentPresenter. 回答1: I would do it like this:

Disallow/Block selection of disabled combobox item in wpf

我是研究僧i 提交于 2019-12-17 09:46:51
问题 I'm writing an application wherein I would like to disable few items in the ComboBox and also want to disallow/block selection of disabled items. Please note ComboBox in main window has another ComboBox as ComboBox Item init (that is decided at run time by data template selector). With below code I'm able to disable a ComboBox within ComboBox but it would not stop user from selecting that disabled ComboBox item. Any help in disallow/block selection of disabled items would be helpful. Below

How can I change the width of a JComboBox dropdown list?

人走茶凉 提交于 2019-12-17 09:33:16
问题 I have an editable JComboBox which contains a list of single letter values. Because of that the combobox is very small. Every letter has a special meaning which sometimes isn't clear to the user in case of rarely used letters. Because of that I've created a custom ListCellRenderer which shows the meaning of each letter in the dropdown list. Unfortunately this explanation doesn't fit into the dropdown because it is to small, because it has the same width as the combobox. Is there any way to