本文介绍了wpf验证组合框文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
There are 2 comboboxes and 2 textboxes in my wpf project.
I want to set fill in validation.
It says "Fill in properly" even I fill them properly.
Below is my code:
private void Reg()
{
if (txtDate.Text != null & txtTime.Text != null & cmbGroup1.SelectedIndex > 0 & cmbName1.SelectedIndex > 0)
{
MySqlConnection con = new MySqlConnection(constr);
MySqlCommand cmd = new MySqlCommand("INSERT INTO Regiter(Date,Time,Image_ID,Students_ID) "
+ "VALUES ('" + txtDate.Text + "','" + txtTime.Text + "','" + getMaxRasmID() + "','" + getStudentsID() + "')", con);
con.Open();
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("Registered");
}
con.Close();
}
else
{
MessageBox.Show("Fill in properly");
}
}
推荐答案
这篇关于wpf验证组合框文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!