combobox 相关问题

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

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

这是我在这个网站或其他地方都没有找到的情况: 我的 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

wpf组合框如何处理PreviewMouseWheel

我想将 MouseWheel 的处理程序添加到 ComboBox,但我不知道如何操作。 原因是我在 ScrollViewer 内的 DataGrid 内的 ComboBox 上遇到滚动问题,请参阅此处,我...

回答 1 投票 0

Access 中组合框中的唯一值

好吧,这是我的困境。 (使用 Access 2010) 我创建了一个访问数据库,来管理我工作中的计算机硬件库存。 我创建了一个带有未绑定组合框的表单,仅允许唯一值。 ...

回答 3 投票 0

我可以在 WinForms 中禁用组合框而不将其灰显吗?

有没有办法禁用组合框的值更改而不将其在 Windows 窗体中灰显?我看到了一些帖子,但它们是针对 WPF 的,对我的情况没有帮助。

回答 5 投票 0

C# dataGridView 组合框 AlternatingRowsDefaultCellStyle

我有一个带有 AlternatingRowsDefaultCellStyle 的 dataGridView 一切都很好,一行是白色的,接下来所有列都是灰色的。 但现在我添加了一列 DataGridViewComboBoxDisplayStyle.DropDownButton 并为此

回答 1 投票 0

如何为数据绑定组合框预定义组合框项?

我想允许用户选择串口的波特率。 我创建了一个与串口波特率绑定的文本框,如下所示,它可以工作。 我想允许用户选择串口的波特率。 我创建了一个与串口波特率绑定的文本框,如下所示,它可以工作。 <TextBox x:Name="tbbaudRate" Text="{Binding SerialPort.BaudRate}" /> 我的问题是,有效波特率的设置是有限的。有效波特率为 { 75, 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 }。我想将文本框更改为列出有效波特率值的组合框。 这就是我所做的。 <ComboBox x:Name="tbbaudRate" Text="{Binding SerialPort.BaudRate}" > <ComboBoxItem Content="75"/> <ComboBoxItem Content="110"/> <ComboBoxItem Content="300"/> <ComboBoxItem Content="1200"/> <ComboBoxItem Content="2400"/> <ComboBoxItem Content="4800"/> <ComboBoxItem Content="9600"/> <ComboBoxItem Content="19200"/> <ComboBoxItem Content="38400"/> <ComboBoxItem Content="57600"/> <ComboBoxItem Content="115200"/> </ComboBox> 虽然这有效,但我几乎没有问题。 当我第一次加载窗口时,未选择波特率的默认值(9600)。 这看起来不太优雅。实现这一目标的最佳方法是什么? 供参考,这是我的串口类。也像上面的代码一样丑陋。我使用 resharper 自动生成 notificationpropertychange 代码。 class SerialComm : INotifyPropertyChanged { private int[] ValidBaudRate = new[] { 75, 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 }; //Dont know how to use this private int[] ValidDataBits = new[] { 5, 6, 7, 8, 9 }; //Dont know how to use this private SerialPort _serialPort; public SerialComm() { _serialPort = new SerialPort(); } public SerialPort SerialPort { get { return _serialPort; } set { _serialPort = value; OnPropertyChanged("SerialPort"); SerialPort.GetPortNames(); } } #region Autogenerate by resharper public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } #endregion } 像这样改变你的组合框: <ComboBox Name="comboBox1" Width="120" ItemsSource="{Binding Path=ValidBaudRateCollection}"> <ComboBox.ItemTemplate> <DataTemplate> <Label Content="{Binding }"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> 将这些添加到您的SerialComm课程中: public ObservableCollection<int> ValidBaudRateCollection; public SerialComm() { this.ValidBaudRateCollection = new ObservableCollection<int>(this.ValidBaudRate); _serialPort = new SerialPort(); } 最后将它们添加到您的Window中的某个位置(例如构造函数) SerialComm s = new SerialComm(); comboBox1.DataContext = s; comboBox1.ItemsSource = s.ValidBaudRateCollection; comboBox1.SelectedIndex = 6; 注意: 这样您就可以绑定组合框值,但是将 ObservableCollection 添加到似乎位于另一层的类中可能在架构上不正确。 要使“9600”成为默认波特率,您需要添加以下行 myComboBox.SelectedIndex = 7; 9600 排在第七位 希望有帮助... 旧线程,但让我走上了正轨: 通过添加 SelectedValuePath="Content" 并将其保存到 SelectedValue 来解决它。 <ComboBox SelectedValue="{Binding LaserBaudRate, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Content"> <ComboBoxItem Content="75" /> <ComboBoxItem Content="110" /> <ComboBoxItem Content="300" /> <ComboBoxItem Content="1200" /> <ComboBoxItem Content="2400" /> <ComboBoxItem Content="4800" /> <ComboBoxItem Content="9600" /> <ComboBoxItem Content="19200" /> <ComboBoxItem Content="38400" /> <ComboBoxItem Content="57600" /> <ComboBoxItem Content="115200" /> </ComboBox> 只需添加: private int selectedBaudRate; public Constructor() { SelectedBaudRate = Properties.Settings.Default.SelectedBaudRate; } public int SelectedBaudRate { get => selectedBaudRate; set { if (value != selectedBaudRate) { OnPropertyChanging(); selectedBaudRate = value; Properties.Settings.Default.SelectedBaudRate = value; OnPropertyChanged(); } } } <ComboBox Width="80" ItemsSource="{Binding AvailableBaudRate}" SelectedValue="{Binding SelectedBaudRate, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" />

回答 4 投票 0

如何禁用 Ext JS 中组合框中的项目?

如何禁用 Ext JS 组合框中的特定项目? 例如我有这些记录 row_1_type_1 row_2_type_2 row_3_type_3 我想禁用第三行,即它应该留在 co...

回答 4 投票 0

如何将一组组合框重置回无选择tkinter?

我将 ttkbootstrap 与 tkinter 一起使用,我有 15 个 ttkbootstrap 组合框,如果按下按钮,我想将它们重置为无选择。我尝试了在某处找到的这段代码,但它什么也没做。我...

回答 1 投票 0

通过属性绑定禁用组合框的切换按钮或弹出下拉菜单

我希望能够通过在 ViewModel 中设置属性来禁用用户的组合框。 最后,在某些情况下,用户应该只能查看 SelectedItem。 有一些

回答 2 投票 0

uwp:如何在 x:DataType 之外的 DataTemplate 内绑定数据?

我有 MyPage.xaml 和 MyPage.xaml.cs 文件。 在 .xaml 文件中,我编写了如下数据模板: ...

回答 2 投票 0

VB.NET Combobox 中手动填充数据的字符串类型值成员和显示成员

我想从手动输入数据“C|贷方,D|借方”的选定组合框项目中存储C和D。以下是我的代码 FillCombosWithValueMDisplayM(m01OpnCrDr, "C|信用,D|

回答 1 投票 0

SfComboBox 选择框在选择后为空白,直到按下清除按钮

我正在尝试让 Syncfusion SfComboBox (24.2.9) 在 .NET MAUI (8.0.201) for Mac Catalyst 和 UIDeviceFamily 6 中工作。 如果 IsClearButtonVisible 为 false,则选择框在创建

回答 1 投票 0

Excel VBA 用户窗体组合框不显示命名范围列表

我正在尝试使用命名范围“rngEnclosure”填充组合框,但它没有填充组合框,但没有错误消息。奇怪的是我还有一个Combo...

回答 1 投票 0

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