amir3321
پنج شنبه 12 دی 1387, 10:29 صبح
من یک لیست باکس دارم که به بانک بایند شده مخوام آیتمهای انتخاب شده بوسیله کاربر رو به یک تکست باکس بفرستم این کار رو با یک ایتم میتونم ولی برای چند انتخاب نمیدونم چکار کنم
اینم کد من
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString =
"Data Source=takaserver;" +
"Initial Catalog=ofcdb;" +
"Integrated Security=SSPI;";
conn.Open();
string strsql = "select name , serialgroup from ofcuser";
SqlDataAdapter da = new SqlDataAdapter(strsql ,conn );
DataSet ds = new DataSet ();
da.Fill(ds,"ofcuser");
listBox1.DataSource = ds.Tables[0];
listBox1.DisplayMember = "name";
listBox1.ValueMember = "name";
listBox1.DataBindings.Add(new Binding("SelectedValue", ds, "ofcuser.name"));
conn.Close();
}
catch (DataException)
{
MessageBox.Show("خطا در اتصال به دیتابیس ");
listBox1.Enabled = false;
return;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem!=null)
{
string item2 = ((DataRowView)listBox1.SelectedItem)["name"].ToString();
label1.Text = item2;
{
{
اینم کد من
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString =
"Data Source=takaserver;" +
"Initial Catalog=ofcdb;" +
"Integrated Security=SSPI;";
conn.Open();
string strsql = "select name , serialgroup from ofcuser";
SqlDataAdapter da = new SqlDataAdapter(strsql ,conn );
DataSet ds = new DataSet ();
da.Fill(ds,"ofcuser");
listBox1.DataSource = ds.Tables[0];
listBox1.DisplayMember = "name";
listBox1.ValueMember = "name";
listBox1.DataBindings.Add(new Binding("SelectedValue", ds, "ofcuser.name"));
conn.Close();
}
catch (DataException)
{
MessageBox.Show("خطا در اتصال به دیتابیس ");
listBox1.Enabled = false;
return;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem!=null)
{
string item2 = ((DataRowView)listBox1.SelectedItem)["name"].ToString();
label1.Text = item2;
{
{