combobox

Passing id from one combobox to populate second combo box in WPF

◇◆丶佛笑我妖孽 提交于 2019-12-13 21:12:46
问题 How do I pass the categoryId for the selected CategoryName in the first combo box, which would populate the products in the second combo box / the table structure is a below. Table_Category CategoryId CategoryyName Table_Product ProductId ProductName CategoryId ProductPrice ProductUnit Thanks, Hussain Patel 回答1: for the first combo box (cmbcategory) using ADO.NET (code), get category object (containing the categoryId and categoryName) and bind to itemsource property of first combo box

How to update a WPF ComboBox when assigning an object as its SelectedItem?

爱⌒轻易说出口 提交于 2019-12-13 21:12:01
问题 I have a ComboBox which has its ItemsSource bound to an ObservableCollection<CustomObject> where CustomObject has a few properties. Sample class: public class CustomObject : INotifyPropertyChanged { public string Property1 { /*...omitted for brevity...*/ } public string Property2 { /*...omitted for brevity...*/ } public string Property3 { /*...omitted for brevity...*/ } } The SelectedItem property of my ComboBox is bound to a CustomObject property which appears in a DataGrid row. Sample class

JavaFX editable ComboBox with history function

一笑奈何 提交于 2019-12-13 20:12:34
问题 I am attempting to make a JavaFX ComboBox that remembers the history of the entries entered by the user. Adding new items works, but selecting from the drop-down does not. In a nutshell, I am trying to get the control to Add the most recently typed entry to the top, as the first item of the ComboBox . Clear the TextField portion for the next entry. Upon selecting an item from the ComboBox , will copy selection to the TextField , without modifying the ComboBox 's items. Adding new items works

C# Using a list of objects to populate combobox and keeping object properties accessible

让人想犯罪 __ 提交于 2019-12-13 19:34:25
问题 I'm having some difficulty populating a combobox with the values inside a list. The list contains the following. public List<Classroom> classes= new List<Classroom>(); CONTAINS: public List<Students> Members{ get;} public Classroom(string naam, string code, int maxPersonen) { Name= name; Code = code; MaxPeople= maxpeople; Members= new List<Members>(); } i'm trying to populate my combobox with List classes and show each of these classes as following (currently using this): foreach(Classroom

VBA Combobox / automatically generate code

余生长醉 提交于 2019-12-13 18:14:11
问题 I've got a question concerning combobox in Excel. I've got an excel sheet that by default contains two comboboxes and their number is described by a variable x (x=2 by default). Each combobox is scripted to behave in a particular way in subs, for example I've got: private sub ComboBox1_DropButtonClick(). Nonetheless, sometimes I need to increase the number of these boxes by changing the value of X. I may need up to 10 comboboxes in total. Now the question is whether there's any way in which I

What is the preferred method of refreshing a combo box when the data changes?

人走茶凉 提交于 2019-12-13 17:28:24
问题 What is the preferred method of refreshing a combo box when the data changes? If a form is open and the combo box data is already loaded, how do you refresh the contents of the combo box without the form having to be closed and reloaded? Do you have to do something on the Click event on the combo box? This would seem to be a potential slow down for the app if there is a hit to the database every time someone clicks on a combo box. 回答1: You must determine: 1) When does you data change? If it

Event firing when ComboBox.Items count changed?

孤街浪徒 提交于 2019-12-13 17:27:26
问题 I couldn't find a proper event which fires when my ComboBox.Items count changed. Is there any way to do so? 回答1: Bind ComboBox ItemsSource to ObservableCollection, then you can catch the event CollectionChanged of ObservableCollection EDIT: In wpf it is recommended to use binding instead of accessing UI element properties directly, of course better to use MVVM, but you can live without it too in your Windows or UserControls C# code you can keep property like this public ObservableCollection

How do I get the ToggleButton from ComboBox Control

断了今生、忘了曾经 提交于 2019-12-13 16:36:52
问题 I was checking control template of ComboBox(http://msdn.microsoft.com/en-us/library/ms752094(v=vs.110).aspx), where they have used Toggle Button to toggle the Popup. Is there a way I could get the toggle button from code behind? I had tried this, but to no avail :-( var uiElement = (ComboBox)sender; var toggleButton = uiElement.FindResource(typeof(ToggleButton)) as ToggleButton; 回答1: If you now the name of the ToggleButton then you can use following code: var uiElement = (ComboBox)sender; var

How to add a focus style to an editable ComboBox in WPF

自古美人都是妖i 提交于 2019-12-13 16:23:37
问题 I've been looking at the following example on how to style the ComboBox , but I haven't been able to create a focus effect when going into an editable combo box. Whenever the ComboBox receives focus, it should go into edit mode and the component should have a focus style. The basic problem is that whenever I go into the edit mode, it's not the surrounding ComboBox which actually has the focus, but the text subcomponent and I haven't been able to create a Trigger on the text component which

Deselect combobox item

陌路散爱 提交于 2019-12-13 16:19:28
问题 I have a databound combobox: using(DataContext db = new DataContext()) { var ds = db.Managers.Select(q=> new { q.ManagerName, q.ManagerID}); cmbbx_Managers.BindingContext = new BindingContext(); cmbbx_Managers.DataSource = ds; cmbbx_Managers.DisplayMember = "ManagerName"; cmbbx_Managers.ValueMember = "ManagerID"; } When the form loads neither item is selected, but when the user chooses an item it cannot be deselected. I tried to add cmbbx_Managers.items.Insert(0, "none") , but it does not