我在C#中有一个使用a的表单ComboBox.如何防止用户ComboBox在C#中手动输入文本?
this.comboBoxType.Font = new System.Drawing.Font("Arial", 15.75F);
this.comboBoxType.FormattingEnabled = true;
this.comboBoxType.Items.AddRange(new object[] {
"a",
"b",
"c"});
this.comboBoxType.Location = new System.Drawing.Point(742, 364);
this.comboBoxType.Name = "comboBoxType";
this.comboBoxType.Size = new System.Drawing.Size(89, 32);
this.comboBoxType.TabIndex = 57;
Run Code Online (Sandbox Code Playgroud)
我希望ABC成为唯一的选择.
可能重复:
如何使用C#检查打印机是否已安装并准备就绪?
当我遇到一般错误的异常时,我使用PDFCreator从C#程序中生成pdf文件,我想知道如何检查打印机本身是否存在于系统中。
像文件存在检查。
有这样的选择吗?
我正在编写一个C#程序来将数据输入SQL Server 2008数据库.
我使用以下函数将信息输入数据库
public bool AddSupplier(string name, string contactPerson, string telephone, string fax, string type, string payment, string comments)
{
_cmd.CommandText =
"INSERT INTO suppliers (name,contactPerson,telephone,fax,type,payment,active,comments) VALUES (@name,@contactPerson,@telephone,@fax,@type,@payment,@active,@comments);";
_cmd.Parameters.Clear();
_cmd.Parameters.AddWithValue("@name", name);
_cmd.Parameters.AddWithValue("@contactPerson", contactPerson);
_cmd.Parameters.AddWithValue("@telephone", telephone);
_cmd.Parameters.AddWithValue("@fax", fax);
_cmd.Parameters.AddWithValue("@type", type);
_cmd.Parameters.AddWithValue("@payment", payment);
_cmd.Parameters.AddWithValue("@active", 1);
_cmd.Parameters.AddWithValue("@comments", comments);
_con.Open();
_cmd.ExecuteNonQuery();
_con.Close();
return true;
}
Run Code Online (Sandbox Code Playgroud)
这很好用,我可以用希伯来语添加信息,它会显示在数据库中.
当我尝试使用此功能编辑它时
public bool EditSupplier(int supplierId,string name, string contactPerson, string telephone, string fax, string type, string payment, string comments)
{
_cmd.CommandText = "UPDATE suppliers SET name='" + name …Run Code Online (Sandbox Code Playgroud)