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
anurag guhe
NA
43
6.7k
clear & remove list from 2 listboxes
Jul 7 2016 10:15 AM
hey guys can u tell me i have problem in my windows form application
in my windows form there are 1 combobox , 2 listbox , 1 textbox , 2 button (one is clear & other is remove)
combobox containing service_name which are fetching from sql
listbox1 containing service_name & service_price after selecting service_name from combobox (i.e listbox1 is show in 1 row swiftcar=1000 , in 2nd row hondacity=5000)
listbox2 containing only service_price after selecting service_name from combobox (i.e listbox2 is show in 1 row 1000 , in 2nd row 5000)
textbox show addition of service_price 6000 (i.e. 1000+5000=6000)
now i want that when i am clicking on remove button it can be remove the values from both listbox1 and listbox2 when i am selecting the values from eigther listbox1 or listbox2
& reduced the service_price values from textbox also
and another solution which i want is on clear button when clicking on clear button it can be clear the all values from both listbox1 and listbox2 & textbox will show zero value
following are the my code now plz provide solution for me on remove and clear button
private void Combo_Services_Customer_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=ABC\\MYSQL;initial catalog=saloon;user id=abc\\Anurag;integrated security=sspi");
con.Open();
SqlCommand cmd = new SqlCommand("select Service_Price from Customer_Services where Service_Name='" + Combo_Services_Customer.SelectedItem.ToString() + "'", con);
cmd.Parameters.Add(new SqlParameter("@Customer_Services", Combo_Services_Customer.SelectedItem.ToString()));
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
listBox2.Items.Add(Convert.ToString(int.Parse(dr[0].ToString())));
listBox1.Items.Add(string.Format("{0} = {1}", Combo_Services_Customer.SelectedItem, listBox1.Text = Convert.ToString(int.Parse(dr[0].ToString()))));
decimal sum = 0;
for (int i = 0; i < listBox3.Items.Count - 0; i++)
{
sum += Convert.ToDecimal(int.Parse(listBox2.Items[i].ToString()));
}
Txt_Amt_Services_Customer.Text = Convert.ToString(sum);
}
con.Close();
}
Reply
Answers (
2
)
Select Item To calculate in multilplication
how to delete an image from a picturebox using a button?