private ComboBoxEx CreatePropertyComboBox(Entity entity, Property property) { var cb = CreateComboBox(); int index = -1; int i = 0; Func <Property, string> function = p => p.Name; if (entity != null) { foreach (var item in entity.Properties) { var cbi = new ComboBoxItemEx <Property>(item, function); cb.Items.Add(cbi); if (property == item) { index = i; } i++; } } cb.SelectedIndex = index; cb.SelectedIndexChanged += control_SelectedIndexChanged; return(cb); }
private void TextChanged() { try { _comboBox.Items.Clear(); if (!string.IsNullOrEmpty(_textBox.Text) && _textBox.Text.Length >= _searchThreshold) { foreach (AutoCompleteEntry entry in _autoCompletionList) { if (!entry.KeywordStrings.Any(word => word.Contains(_textBox.Text))) { continue; } ComboBoxItemEx cbItem = new ComboBoxItemEx { Content = entry.ToString(), Entry = entry }; _comboBox.Items.Add(cbItem); } _comboBox.IsDropDownOpen = _comboBox.HasItems; } else { _comboBox.IsDropDownOpen = false; } } catch { // ignored } }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_comboBox.SelectedItem != null) { // _insertText = true; ComboBoxItemEx cbItem = (ComboBoxItemEx)_comboBox.SelectedItem; // _textBox.Text = cbItem.Content.ToString(); OnSelecteEvent(cbItem.Entry.Id); } }
private void SetSelectedValue <T>(ComboBoxEx boxEx, T value, Func <T, string> getName) where T : class { ComboBoxItemEx <T> item = boxEx.Items.OfType <ComboBoxItemEx <T> >().FirstOrDefault(i => i.Object == value); if (item == null) { item = new ComboBoxItemEx <T>(value, getName); boxEx.Items.Add(item); } boxEx.SelectedItem = item; }
private void SetSelectedObject <T>(ComboBox comboBox, T value) where T : class { for (int i = 0; i < comboBox.Items.Count; i++) { ComboBoxItemEx <T> item = (ComboBoxItemEx <T>)comboBox.Items[i]; if (item.Object == value) { comboBox.SelectedIndex = i; } } }
private void PopulateVariableTypes() { comboBoxType.Items.Clear(); userOptionTypes.Clear(); var optionTypes = Project.Instance.GetUserOptionTypes(); foreach (var userOptionType in optionTypes) { var ci = new ComboBoxItemEx <Type>(userOptionType, GetUserFriendlyName); comboBoxType.Items.Add(ci); userOptionTypes.Add(userOptionType); } }
private object GetValueFrom(Control control, IUserOption option) { if (VirtualPropertyHelper.IsEnumType(option)) { ComboBoxItemEx <object> item = ((ComboBox)control).SelectedItem as ComboBoxItemEx <object>; if (item == null) { return(null); } return(item.Object); } if (VirtualPropertyHelper.IsStringType(option)) { return(control.Text); } if (VirtualPropertyHelper.IsIntegerNumericType(option)) { return(control.Text.As <int>()); } if (VirtualPropertyHelper.IsCharType(option)) { return(control.Text[0]); } if (VirtualPropertyHelper.IsDecimalNumericType(option)) { return(control.Text.As <decimal>()); } if (VirtualPropertyHelper.IsBoolType(option)) { return(((CheckBox)control).Checked); } return(null); }
private void PopulateVariableTypes() { comboBoxType.Items.Clear(); userOptionTypes.Clear(); var optionTypes = Project.Instance.GetUserOptionTypes(); foreach (var userOptionType in optionTypes) { var ci = new ComboBoxItemEx<Type>(userOptionType, GetUserFriendlyName); comboBoxType.Items.Add(ci); userOptionTypes.Add(userOptionType); } }
private T GetSelectedValue <T>(ComboBoxEx boxEx) where T : class { ComboBoxItemEx <T> item = boxEx.SelectedItem as ComboBoxItemEx <T>; return(item == null ? null : item.Object); }
private ComboBoxEx CreatePropertyComboBox(Entity entity, Property property) { var cb = CreateComboBox(); int index = -1; int i = 0; Func<Property, string> function = p => p.Name; if (entity != null) foreach (var item in entity.Properties) { var cbi = new ComboBoxItemEx<Property>(item, function); cb.Items.Add(cbi); if(property == item) index = i; i++; } cb.SelectedIndex = index; cb.SelectedIndexChanged += control_SelectedIndexChanged; return cb; }