下拉框有DropDownStyle这一属性,把DropDownStyle类型选为DropDownList,则下拉框只能选择不能输入了。但是这时的下拉框是没有默认值的,即使在Text属性中输入默认值,也不起作用。就要在(某某某.Designer.cs)文件中修改。
这是没有修改的:
this.NameTemplateBox.Cursor = System.Windows.Forms.Cursors.Default;
this.NameTemplateBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.NameTemplateBox.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NameTemplateBox.FormattingEnabled = true;
this.NameTemplateBox.Items.AddRange(new object[] {
"-- choose the template --",
C#中的ComboBox实现只能选择不能输入,且下拉框中有默认值。
最新推荐文章于 2023-07-12 13:02:03 发布