如何将组合的默认值设置为“ - 选择 - ” [英] How to set default value of combo as "--select--"
本文介绍了如何将组合的默认值设置为“ - 选择 - ”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在windowsform应用程序中将组合框的默认值设置为--select--
How to set default value of combobox as "--select--" in windowsform application
推荐答案
您有两种可能:
Combobox.SetCurrentValue [ ^ ]
SetCurrentValue
设置依赖项属性的值而不更改其值源。
或
Combobox.SetValue [ ^ ]
SetValue
设置依赖项属性的本地值。
查看其他 Combobox [ ^ ]属性(SelectedValue,SelectedIndex,SelectedItem)取决于您当前的.NET Framework版本。
You got 2 possibilities:
Combobox.SetCurrentValue[^]
SetCurrentValue
sets the value of a dependency property without changing its value source.
or
Combobox.SetValue[^]
SetValue
sets the local value of a dependency property.
Check other Combobox[^] properties (SelectedValue, SelectedIndex, SelectedItem) depending of your current .NET Framework version.
ComboBox myCombo;
private void SetAsDefault()
{
// this sets the combobox to the first item
// to change which item will be selected change the index;
// if you want to set the combobox to have nothing selected change index to -1
int index = 0;
myCombo.SelectedIndex = index;
}
这篇关于如何将组合的默认值设置为“ - 选择 - ”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文