combobox 相关问题

Combobox允许从多个选项中选择一个(类似于下拉列表),或者键入自定义选项。

无法在选项卡或单选组组件内使用 vue headless ui 组合框滚动条

我无法在无头 UI 选项卡组件中使用滚动条,当我单击并滚动滚动条时,组合框将关闭。ComboBoxInput 出现关闭滚动条的问题。 那一刻...

回答 1 投票 0

VB |将 SQL 查询加载到组合框中

我正在尝试用 SQL 结果填充组合框 我认为我的问题是处理数据表形式的数据。 将 sql 变暗为字符串 昏暗的 sqlquery 作为字符串 将连接字符串变暗为字符串 ...

回答 2 投票 0

从 UserControl 公开 ComboBox.ItemsSource

我创建了一个简单的 WPF UserControl,其中包含一个 ComboBox,我想公开后者的 ItemsSource 属性以从父视图绑定集合。 这是 xaml ...

回答 1 投票 0

WPF/C# - dropbox 样式 - 无法单击 ToggleButton 背景

我到处收集代码来制作自定义组合框 但我只能点击箭头来选择一个项目 我希望能够单击整个 ToggleButton,而不仅仅是箭头 由于某种原因

回答 1 投票 0

代码在一个子项中给出类型不匹配,但在另一个子项中没有给出类型不匹配

您好,我有一个用户表单,其中包含 3 个组合框:TaskStartTime、TaskFinishTime 和 Task_Duration。 计划是您更改用户表单中的开始或结束值,并且持续时间值发生变化...

回答 1 投票 0

如何使用组合框中放入的另一个字符串值列表的输入来获取列表的整数值?

我对 Dearpygui 比较陌生,并且在尝试使用组合框使用项目中另一个列表的字符串值从存储在 user_data 中的列表中回调指定的 int 值时遇到麻烦...

回答 1 投票 0

带有 contains 的 WPF 组合框文本搜索

我如何使用 contains 而不是 StartsWith 来实现我的 Combobox TextSearch 我如何使用 contains 而不是 StartsWith 来实现我的组合框文本搜索 <rf:ComboBox Grid.Row="1" Grid.Column="5" Width="200" ItemsSource="{Binding Source={StaticResource AccountProvider}}" DisplayMemberPath="Description" SelectedValuePath="IndRekId" IsEmptyItemVisible="True" SelectedValue="{Binding Id, UpdateSourceTrigger=PropertyChanged}" IsTextSearchEnabled="True" TextSearch.TextPath="Description" IsEditable="True"/> 搜索功能可以工作,但我需要匹配子字符串 这里我有一个MVVM框架的例子。 我的xaml文件: <ComboBox Name="cmbContains" IsEditable="True" IsTextSearchEnabled="false" ItemsSource="{Binding pData}" DisplayMemberPath="wTitle" Text="{Binding SearchText ,Mode=TwoWay}" > <ComboBox.Triggers> <EventTrigger RoutedEvent="TextBoxBase.TextChanged"> <BeginStoryboard> <Storyboard> <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsDropDownOpen"> <DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:0"/> </BooleanAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </ComboBox.Triggers> </ComboBox> 我的cs文件: //ItemsSource - pData //There is a string attribute - wTitle included in the fooClass (DisplayMemberPath) private ObservableCollection<fooClass> __pData; public ObservableCollection<fooClass> pData { get { return __pData; } set { Set(() => pData, ref __pData, value); RaisePropertyChanged("pData"); } } private string _SearchText; public string SearchText { get { return this._SearchText; } set { this._SearchText = value; RaisePropertyChanged("SearchText"); //Update your ItemsSource here with Linq pData = new ObservableCollection<fooClass>{pData.ToList().Where(.....)}; } } 您可以看到可编辑的组合框绑定到字符串(SearchText) 一旦发生 TextChanged 事件,就会显示下拉菜单,并且双向绑定会更新值。 当进入 set{} 时,cs 文件中的 ItemsSource 发生了变化;语法。 https://gist.github.com/tonywump/82e66abaf71f715c4bd45a82fce14d80 这个示例看起来像“TextSearch” 在 XAML 文件中,您应该只向组合框“TextContainSearch.Text”添加一个属性: <ComboBox ItemsSource="{Binding Model.formListIntDeviceNumbers}" SelectedItem="{Binding Path=Model.selectedDeviceNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="DeviceNumber" IsEditable="True" c:TextContainSearch.Text="DeviceNumber"> 我们应该在 XAML 文件的标头中添加 using : xmlns:c="clr-namespace:Adaptive.Controls.Extension" *.cs 文件中的 C# 代码: using System; using System.Windows; using System.Windows.Controls; namespace Adaptive.Controls.Extension { public sealed class TextContainSearch : DependencyObject { public static void SetText(DependencyObject element, string text) { var controlSearch = element as Control; if (controlSearch != null) controlSearch.KeyUp += (sender, e) => { if (sender is ComboBox){ var control = sender as ComboBox; control.IsDropDownOpen = true; var oldText = control.Text; foreach(var itemFromSource in control.ItemsSource){ if (itemFromSource != null) { Object simpleType = itemFromSource.GetType().GetProperty(text).GetValue(itemFromSource, null); String propertOfList = simpleType as string; if (!string.IsNullOrEmpty(propertOfList) && propertOfList.Contains(control.Text)) { control.SelectedItem = itemFromSource; control.Items.MoveCurrentTo(itemFromSource); break; } } } control.Text = oldText; TextBox txt = control.Template.FindName("PART_EditableTextBox", control) as TextBox; if (txt != null) { txt.Select(txt.Text.Length, 0); } } }; } } } 试试这个: <ComboBox Padding="3,5" MinWidth="150" SelectedItem="{Binding NewBoxRequest}" ItemsSource="{Binding Requests}" DisplayMemberPath="SN" IsEditable="True" StaysOpenOnEdit="True" Text="{Binding SnFilter,UpdateSourceTrigger=PropertyChanged}"> </ComboBox> 查看型号: private string snFilter; public string SnFilter { get { return snFilter; } set { snFilter = value; RaisePropertyChanged(); RaisePropertyChanged(nameof(Requests)); } } private List<Request> requests; public List<Request> Requests { get => string.IsNullOrEmpty(SnFilter) || requests.Any(r => r.SN == SnFilter) ? requests : requests.Where(r => r.SN.Contains(SnFilter)).ToList(); set { requests = value; RaisePropertyChanged(); } } 无法用 string.Contains() 替换 string.StartsWith()。您必须编写自定义组合框。 这篇文章可能会帮助您: http://www.codeproject.com/Tips/631196/ComboBox-with-Suggest-Ability-based-on-Substring-S 我无法让“Set”语法在我的 C# 系统中工作,所以这里是对上面 Wu 的答案的一个小起飞(这是在自定义控件中): <ComboBox IsEditable="True" IsTextSearchEnabled="false" ItemsSource="{Binding pData, RelativeSource = {RelativeSource TemplatedParent}}" DisplayMemberPath="description" Text="{Binding SearchText , RelativeSource = {RelativeSource TemplatedParent}, Mode=TwoWay}" > <ComboBox.Triggers> <EventTrigger RoutedEvent="TextBoxBase.TextChanged"> <BeginStoryboard> <Storyboard> <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsDropDownOpen"> <DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:0"/> </BooleanAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </ComboBox.Triggers> </ComboBox> 在自定义控件中: private async void _Loaded(object sender, RoutedEventArgs e) { var n = await InitializeLabTests; allTests = new ObservableCollection<CommonProcedure>(n); pData = new ObservableCollection<CommonProcedure>(n); } //ItemsSource - pData //There is a string attribute - wTitle included in the fooClass (DisplayMemberPath) private ObservableCollection<CommonProcedure> __pData; public ObservableCollection<CommonProcedure> pData { get { return __pData; } set { __pData = value; RaisePropertyChanged(); } } private string _SearchText; public string SearchText { get { return _SearchText; } set { _SearchText = value; RaisePropertyChanged(); //Update your ItemsSource here with Linq pData = new ObservableCollection<CommonProcedure> ( allTests.Where(q => q.description.Contains(SearchText)) ); } } 唯一显着的区别在于 SearchText 设置器。 ComboBox KeyUp 事件上的动态事件怎么样: <ComboBox DisplayMemberPath="Label" Height="37" Padding="5" SelectedValue="{Binding Client, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding ClientList, UpdateSourceTrigger=PropertyChanged }" IsEditable="True" TextSearch.TextPath="Label" KeyUp="ComboBox_KeyUp" /> 活动: private void ComboBox_KeyUp(object sender, KeyEventArgs e) { var control = sender as ComboBox; if (control == null) { return; } if (control.Tag == null) { control.Tag = control.ItemsSource as List<ComboBoxItemViewModel>; } var filter = control.Text.ToLower(); if (filter.Length == 0) { // If no text, show all items control.ItemsSource = control.Tag as List<ComboBoxItemViewModel>; } else { var dataSource = control.Tag as List<ComboBoxItemViewModel>; if (dataSource == null) return; // Filter items based on the text entered control.ItemsSource = dataSource.Where(item => item.Label.ToLower().Contains(filter)).ToList(); } } //Just replace the List<ComboBoxItemViewModel> with your ViewModel

回答 6 投票 0

python tkinter 奇怪的 { 在列表中

我在选择部分中遇到了这个 {}。 即使在选择框中我也遇到了麻烦。 仅当列表中存在空格时才会发生这种情况。 将 tkinter 导入为 tk 从 tkinter 导入 ttk 所有用户 = [(7, '

回答 1 投票 0

组合框在搜索文本时选择第一项

我有一个组合框,我可以在其中输入文本,它会根据包含该文本的项目列表建议结果。一切似乎都工作正常,除了当我输入第一个字母时,

回答 1 投票 0

C# WPF Combobox 有两列,如何获取所选项目?

我有一个组合框: 我有一个组合框: <ComboBox x:Name="cmbOrganization_Config_AddSalGrp" FontSize="20" Margin="5 0 5 5" SelectedItem="{Binding OrgID}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Organization_Name}" Margin="0 0 20 0" Visibility="Visible"/> <TextBlock Text="{Binding OrgID}" Visibility="Visible"/> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> 我有这个隐藏代码: try { // Let the SqlCommand object know which stored procedure to execute SqlCommand cmd = new SqlCommand("tuc_salary_grouping_add", con); //Specify that it is a stored procedure and not a normal proc cmd.CommandType = System.Data.CommandType.StoredProcedure; // cmd.Parameters.AddWithValue("@SalaryGroupingName", this.SalaryGroupingConfig_add.Text); cmd.Parameters.AddWithValue("@Organization_ID", this.cmbOrganization_Config_AddSalGrp.SelectedItem); cmd.Parameters.AddWithValue("@Organization_ID", this.cmbOrganization_Config_AddSalGrp.Text); cmd.Parameters.AddWithValue("@Organization_ID", (this.cmbOrganization_Config_AddSalGrp.SelectedItem as ComboBoxItem).Content.ToString()); cmd.Parameters.AddWithValue("@Notes", string.Empty); // Open the connection and execute the stored procedure con.Open(); int rowsAffected = cmd.ExecuteNonQuery(); Debug.WriteLine($"SQL> New record insert was successfully - [{rowsAffected}]"); return true; } 用户选择该项目后,我需要从组合框中获取“OrgID”。 我尝试了3种不同的方法,但都不起作用。我的代码不是 MVVM 形式。 OrgID 是一个整数。我感谢你的帮助。 您可以使用 SelectionChanged 事件来检索所选项目。就像下面的例子: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { var Items = new List<ItemsOrga> { new ItemsOrga("Id1", "Orga1"), new ItemsOrga("Id2", "Orga2"), new ItemsOrga("Id3", "Orga3") }; cmbOrganization_Config_AddSalGrp.ItemsSource = Items; } private void cmbOrganization_Config_AddSalGrp_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { var SelectedItem = e.AddedItems[0] as ItemsOrga; Debug.WriteLine(SelectedItem.OrgID); } } } public class ItemsOrga { public string Organization_Name { get; set; } public string OrgID { get; set; } public ItemsOrga(string OrgID, string Organization_Name) { this.OrgID = OrgID; this.Organization_Name = Organization_Name; } }

回答 1 投票 0

EXT 4.2 使用 XTemplate 对结果进行 ComboBox 分组

我正在尝试对从商店获得的结果进行分组以显示在 ComboBox 内。 我有一个如下所示的组合框: 我需要它看起来像这样: 这意味着按类别分组...

回答 6 投票 0

如何使用 pywinauto 选择没有标题的组合框

在我的Windows应用程序中,有三个没有标题但有不同列表项的组合框。如何根据 ComboBox 包含的项目选择正确的 ComboBox。如果我只选择 Control_Type 我会得到

回答 1 投票 0

使用两个不同表中两列的所有数据填充普通单列组合框

这是我在这个网站或其他地方都没有找到的情况: 我的 VBA 用户表单上有一个组合框“数字”。我想用选项卡第 1 列中的数据填充它...

回答 3 投票 0

WPF组合框绑定空值

我有一个 wpf 组合框,它绑定到我的视图模型中的 IEnumerable 集合。首次绑定组合框时,选择 null。当在组合框中选择任何其他值时,空值不可用...

回答 1 投票 0

EXTJS 组合框工具提示

我有一个组合框,其数据使用存储从 SQL 数据库填充。我想显示组合框中每个项目的工具提示,这些工具提示也存储在

回答 1 投票 0

如何将选择事件添加到自动完成组合框?

我有这个组合框 @change 调用 API + 填充列表 - 完成 ✅ @select doSomething() - 未完成 ❌ 我很难检测出选择了什么。前任。如果我选择“马萨诸塞州”我想要...

回答 2 投票 0

NextJS 中的组合框

在 NextJS Web 应用程序中使用组合框的最简单方法是什么? 虽然这个问题看起来很基本,但我在网上查看过,但没有找到任何简单且可行的解决方案。

回答 1 投票 0

ComboBox 的编辑框部分会被自动选择

我有一个小问题困扰了我几个小时。 在我的 WinForms (.NET 3.5) 应用程序中,我在运行时在 TableLayoutPanel 中创建一些组合框 (DropDownStyle = DropDown) 并填充...

回答 9 投票 0

C# - Winforms - 组合框 - 避免选择更新数据源的第一项

我的应用程序中有一个组合框,其中的项目根据您可以在文本字段中输入的搜索文本异步加载。 这工作正常,但每次第一个项目的文本都是

回答 2 投票 0

Blazor 与 InputSelect 的双向数据绑定永远不会进入 VM 属性集

在 Blazor 组件内,我尝试将视图模型类的实例绑定到 InputSelect,以便我可以为枚举属性选择一个值。虚拟机还有一个字符串属性,我可以绑定到文本

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.