hi
I have a problem of counting number listed in my listbox
my list box databinded by sql
I wanna to add the whole numbers on my

public string connString = "server=(local)\\SQLEXPRESS;database=PWA_RES;Integrated Security=SSPI";
        public int pul;
        private void Form1_Load(object sender, EventArgs e)
        {            
            string sql = @"select name,price from main_course ";

            SqlConnection conn = new SqlConnection(connString);
            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            da.Fill(dataSet1, "main_course");
            DataTable dt = dataSet1.Tables["main_course"];

            listBox1.DataSource = dt;
            listBox1.DisplayMember = "name";

            label1.DataBindings.Add("text", dt, "name");
        }

         private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBox2.Items.Add(label1.Text);                  
        }
          private void button3_Click(object sender, EventArgs e)
        {
            pul = 0;
            for (int i = 0; i <= listBox5.Items.Count;i++ )
         {
                pul =pul +  Convert.ToInt32(listBox5.Items[i].ToString()) ;

           }
           MessageBox.Show(pul.ToString());

        }

list box
thanks

Is there a specific problem with your code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.