combobox

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

混江龙づ霸主 提交于 2019-12-17 09:33:00
问题 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

Binding an enum to a WinForms combo box, and then setting it

雨燕双飞 提交于 2019-12-17 05:45:10
问题 a lot of people have answered the question of how to bind an enum to a combo box in WinForms. Its like this: comboBox1.DataSource = Enum.GetValues(typeof(MyEnum)); But that is pretty useless without being able to set the actual value to display. I have tried: comboBox1.SelectedItem = MyEnum.Something; // Does not work. SelectedItem remains null I have also tried: comboBox1.SelectedIndex = Convert.ToInt32(MyEnum.Something); // ArgumentOutOfRangeException, SelectedIndex remains -1 Does anyone

Get the value for a listbox item by index

六月ゝ 毕业季﹏ 提交于 2019-12-17 03:18:31
问题 This must be very easy but I am stuck. I have a listBox with X Items. Each Item has a text description (Which appears in the listBox) and its value(numerical). I want to be able to get the value property of an item, using the index number of the item. 回答1: It would be String MyStr = ListBox.items[5].ToString(); 回答2: Here I can't see even a single correct answer for this question (in WinForms tag) and it's strange for such frequent question. Items of a ListBox control may be DataRowView ,

C# - Fill a combo box with a DataTable

余生长醉 提交于 2019-12-17 03:16:51
问题 I'm used to work with Java where large amounts of examples are available. For various reasons I had to switch to C# and trying to do the following in SharpDevelop: // Form has a menu containing a combobox added via SharpDevelop's GUI // --- Variables languages = new string[2]; languages[0] = "English"; languages[1] = "German"; DataSet myDataSet = new DataSet(); // --- Preparation DataTable lTable = new DataTable("Lang"); DataColumn lName = new DataColumn("Language", typeof(string)); lTable

AutoComplete ComboBox in JavaFX

泪湿孤枕 提交于 2019-12-17 02:41:08
问题 I'm looking for a way to add autocomplete to a JavaFX ComboBox . After searching a lot it's time to ask here. This AutoFillBox is known but not what I'm searching. What I want is a editable combobox and while typing the list should filtered. But I want also to open the list without typing and seeing the whole items. Any idea? 回答1: First, you'll have to create this class in your project: import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event

QT 票据打印系统

做~自己de王妃 提交于 2019-12-16 02:01:16
#include "charge.h" #include "ui_charge.h" #include<QMenuBar> #include <QMainWindow> #include<QWidget> #include <QPrintDialog> #include <QPrinter> #include <QPainter> #include <QStackedWidget> #include <QSqlQuery> #include<QMessageBox> #include <QSqlDatabase> #include <QDebug> #include <QSqlError> #include <QVariantList> #include <QSqlTableModel> #include<QDebug> #include <QFile> #include <QPdfWriter> #include <QFileDialog> #include <QSqlRecord> #include<QProcess> #include<iostream> #include <fstream> #include <windows.h> #include<QInputDialog> #include <QFileDevice> Charge::Charge(QWidget

WPF 2 ComboBox binding problem

对着背影说爱祢 提交于 2019-12-14 04:21:28
问题 I have the following problem: there is a class with a couple of string properties there is a collection of such class entities That collection is shown in tree on the left of some windows and details shown on the right. I'm binding string properties of selected node to comboboxes in details. First combobox always have the same ItemsSource but the second one ItemsSource depends on SelectedItem of the first combo... <ComboBox Grid.Column="1" SelectedIndex="0" x:Name="cbClass" Style="

i have two combo boxes and xml file, i want to populate server name in combo box 1 from xml and based on server name populate second combo box

若如初见. 提交于 2019-12-14 03:59:32
问题 XML : <?xml version="1.0" encoding="utf-8"?> <servers> <server>s2 <database>db1</database> <database>db2</database> </server> <server>s3 <database>db3</database> <database>db4</database> </server> </servers> I want to get database based on server name & return as a list of string type. view : This function will take server name as a parameter from first combo box and based on the will filter database and populate second combobox public List<string> GetDatabases(string serv) { var item = from

ComboBox does not select binding value initially

自古美人都是妖i 提交于 2019-12-14 03:56:05
问题 First of all, not a duplicate. TextBox and CheckBox work correctly, just not ComboBox. Model internal class Word : _Model { public enum Categories { Noun, Verb, } private Categories category; public Categories Category { get { return this.category; } set { this.SetProperty(ref this.category, value); } } } Notify (safe to skip reading this part) internal abstract class _Model : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected bool SetProperty<T>(ref

Setting selected item in combobox bound to dictionary

无人久伴 提交于 2019-12-14 03:51:42
问题 I have a combobox that is bound to a dictionary like this: Dictionary<int, string> comboboxValues = new Dictionary<int, string>(); comboboxValues.Add(30000, "30 seconds"); comboboxValues.Add(45000, "45 seconds"); comboboxValues.Add(60000, "1 minute"); comboBox1.DataSource = new BindingSource(comboboxValues , null); comboBox1.DisplayMember = "Value"; comboBox1.ValueMember = "Key"; I'm getting the key from the SelectedItem like this: int selection = ((KeyValuePair<int, string>)comboBox1