ToolStripComboBox.AutoCompleteCustomSource 屬性

定義

取得或設定當 AutoCompleteSource 屬性設定為 CustomSource 時所用的自訂字串集合。Gets or sets the custom string collection to use when the AutoCompleteSource property is set to CustomSource.

public:
 property System::Windows::Forms::AutoCompleteStringCollection ^ AutoCompleteCustomSource { System::Windows::Forms::AutoCompleteStringCollection ^ get(); void set(System::Windows::Forms::AutoCompleteStringCollection ^ value); };
[System.ComponentModel.Browsable(true)]
public System.Windows.Forms.AutoCompleteStringCollection AutoCompleteCustomSource { get; set; }
member this.AutoCompleteCustomSource : System.Windows.Forms.AutoCompleteStringCollection with get, set
Public Property AutoCompleteCustomSource As AutoCompleteStringCollection

屬性值

屬性

範例

下列程式碼範例示範設定各種 ToolStripComboBox 屬性的語法,包括 AutoCompleteCustomSource 屬性。The following code example demonstrates the syntax for setting various ToolStripComboBox properties, including the AutoCompleteCustomSource property.

// The following code example demonstrates the syntax for setting
// various ToolStripComboBox properties.
// 
toolStripComboBox1.AutoCompleteCustomSource.AddRange(new string[] {
"aaa",
"bbb",
"ccc"});
toolStripComboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
toolStripComboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
toolStripComboBox1.DropDownHeight = 110;
toolStripComboBox1.DropDownWidth = 122;
toolStripComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Standard;
toolStripComboBox1.IntegralHeight = false;
toolStripComboBox1.Items.AddRange(new object[] {
"xxx",
"yyy",
"zzz"});
toolStripComboBox1.MaxDropDownItems = 9;
toolStripComboBox1.MergeAction = System.Windows.Forms.MergeAction.Insert;
toolStripComboBox1.Name = "toolStripComboBox1";
toolStripComboBox1.Size = new System.Drawing.Size(121, 25);
toolStripComboBox1.Sorted = true;
' The following code example demonstrates the syntax for setting
' various ToolStripComboBox properties.
' 
toolStripComboBox1.AutoCompleteCustomSource.AddRange(New String() {"aaa", "bbb", "ccc"})
toolStripComboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
toolStripComboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource
toolStripComboBox1.DropDownHeight = 110
toolStripComboBox1.DropDownWidth = 122
toolStripComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Standard
toolStripComboBox1.IntegralHeight = False
toolStripComboBox1.Items.AddRange(New Object() {"xxx", "yyy", "zzz"})
toolStripComboBox1.MaxDropDownItems = 9
toolStripComboBox1.MergeAction = System.Windows.Forms.MergeAction.Insert
toolStripComboBox1.Name = "toolStripComboBox1"
toolStripComboBox1.Size = New System.Drawing.Size(121, 25)
toolStripComboBox1.Sorted = True

備註

使用 [AutoCompleteCustomSource]、[AutoCompleteMode] 和 [AutoCompleteSource 屬性] 來建立 ToolStripComboBox,藉由比較輸入的前置詞與維護來源中所有字串的首碼,自動完成輸入字串。Use the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource properties to create a ToolStripComboBox that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. 這適用于通常會輸入 Url、位址、檔案名或命令的 ToolStripComboBox 控制項。This is useful for ToolStripComboBox controls in which URLs, addresses, file names, or commands will be frequently entered.

AutoCompleteCustomSource 屬性是選擇性的,但您必須將 AutoCompleteSource 屬性設定為 CustomSource,才能使用 AutoCompleteCustomSourceThe use of the AutoCompleteCustomSource property is optional, but you must set the AutoCompleteSource property to CustomSource in order to use AutoCompleteCustomSource.

您必須同時使用 AutoCompleteModeAutoCompleteSource 屬性。You must use the AutoCompleteMode and AutoCompleteSource properties together.

適用於

另請參閱