ToolStripComboBox.Sorted 屬性

定義

取得或設定值,指出 ToolStripComboBox 中的項目是否會排序。Gets or sets a value indicating whether the items in the ToolStripComboBox are sorted.

public:
 property bool Sorted { bool get(); void set(bool value); };
public bool Sorted { get; set; }
member this.Sorted : bool with get, set
Public Property Sorted As Boolean

屬性值

如果下拉式方塊已排序,則為 true,否則為 falsetrue if the combo box is sorted; otherwise, false. 預設為 falseThe default is false.

範例

下列程式碼範例示範設定各種 ToolStripComboBox 屬性的語法,包括 Sorted 屬性。The following code example demonstrates the syntax for setting various ToolStripComboBox properties, including the Sorted 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

備註

這個屬性會指定 ToolStripComboBox 是否會排序現有的專案,並將新專案加入至清單中適當排序的位置。This property specifies whether the ToolStripComboBox sorts existing entries and add new entries to the appropriate sorted position in the list. 您可以使用這個屬性,自動排序 ToolStripComboBox中的專案。You can use this property to automatically sort items in a ToolStripComboBox. 當專案加入至已排序的 ToolStripComboBox時,專案就會移至已排序清單中的適當位置。As items are added to a sorted ToolStripComboBox, the items are moved to the appropriate location in the sorted list. 當您將屬性設定為 false時,新的專案會新增至現有清單的結尾。When you set the property to false, new items are added to the end of the existing list. 排序不區分大小寫,而且會以字母順序遞增順序。The sort is case-insensitive and in alphabetically ascending order.

適用於