ورود

View Full Version : سوال در خصوص لیست باکس در سی شارپ



Minafarahmand
یک شنبه 07 آبان 1391, 18:45 عصر
سلم دوستان

من این تکه برنامه رو نوشتم اما نمیدونم کجاش مشکل داره که جواب نمیده


برنامه اطلاعات پرسنلی شامل
کد ملی
شماره پرسنلی
نام
نام خانوادگی
و شماره موبایل
میباشد
نباید شماره ملی و پرسنلی تکراری باشه منم تو شرطها ایراد دارم
----------------------


int a, b, f;
string c, d;


a = Int32.Parse(textBox1.Text);
b = Int32.Parse(textBox2.Text);
f = Int32.Parse(textBox5.Text);


// foreach (listItem item in listbox1)
// for (int i = 0; i < listBox1.SelectedItems.Count; ++i)
{
// if (listBox1.Items!=a & listBox1.Items!= b)
// if(listBox1.Items!= a & listBox1!= b)


for (int x = 0; x < listBox1.Items.Count; x++)
{

if( listBox1.Items.Contains(x)==a | listBox1.Items.Contains(x)==b)
{

{ MessageBox.Show(".اطلاعات وارد شده معتبر نیست دوباره امتحان کنید");




}
else


{

textBox1.Text = textBox1.Text.Trim();
textBox2.Text = textBox2.Text.Trim();
textBox3.Text = textBox3.Text.Trim();
textBox3.Text = textBox4.Text.Trim();
textBox3.Text = textBox5.Text.Trim();

(listBox1.Items.Add(a + " /// " + b + " /// " + textBox3.Text + " /// " + textBox4.Text + " /// " + f);

textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
}
}};









private void label6_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{


}

private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Remove(listBox1.SelectedItem);

}

private void button3_Click(object sender, EventArgs e)
{
label6.Text = listBox1.Items.Count.ToString();
}

private void label6_Click_1(object sender, EventArgs e)
{

}
}
}