TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
772.3k
From Listbox1 how to add Particular item to Listbox2 usingc#
Jan 14 2013 2:12 AM
From Listbox1 how to add Particular item to Listbox2 using c sharp in windows application
i am doing application using List box in c sharp in windows application.
Design as follows;
Listbox1 Buttons Listbox2
Ram ADD
Sam ADD ALL
Suresh Remove
Vignesh Remove All
Load
Clear
SqlConnection con = new SqlConnection(" Data Source=INDIA;Initial Catalog=HIMTTESTing;Integrated Security=True");
Code as follows for button(Load)
private void Btn_Load_Click(object sender, EventArgs e)
{
string sql = "select Faculty_Name from Tb_SCH_Faculty_List";
DataSet mydataset = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
adp.Fill(mydataset,"Tb_SCH_Faculty_List");
DataTable mydatatable = mydataset.Tables[0];
DataRow temprow = null;
foreach (DataRow tempRow_Variable in mydatatable.Rows)
{
temprow = tempRow_Variable;
Lb_Faculty_Name.Items.Add((temprow["Faculty_Name"]));
}
}
Code as follows for button(ADD ALL)
private void Btn_Add_All_Click(object sender, EventArgs e)
{
string com = " Select Faculty_Name from Tb_SCH_Faculty_List";
DataSet mydataset = new DataSet();
SqlDataAdapter adpt = new SqlDataAdapter(com, con);
adpt.Fill(mydataset, "Tb_SCH_Faculty_List");
DataTable mydatatable = mydataset.Tables[0];
DataRow temprow = null;
foreach (DataRow tempRow_Variable in mydatatable.Rows)
{
temprow = tempRow_Variable;
Lb_Selected_Faculty.Items.Add((temprow["Faculty_Name"]));
}
}
Both Load and ADD All Button working fine.
Output shows as;
when i click the Load (Button)all faculty name is retrieved from the data base and displayed in the Lisbox1.
similarly when i click the ADD ALL (Button)all faculty name is displayed in the Lisbox2.
the above two buttons Load and ADD ALL is working fine.
in the ADD button;
when i click the Load button all names are retrieved from the data base and displayed in the Listbox1,in the Listbox1 when i select a Particular name and click the ADD button the particular name want to display in to the Listbox2.
i wan the output as follows;
Listbox1 Buttons Listbox2
Ram ADD
when i select and click the ADD Button the Ram (name) Listbox1 want to goes to Listbox2.but in the Listbox1 ram name should be there not clear.
for that how to write the code.
Reply
Answers (
2
)
Search Functionality in MasterPage
how to zoom in datagridview like excel?