hey people. ok.. this is what i NEED to do..
Task

  1. User will add TODO list in the textbox shown in the GUI Windows Form.
  2. User will also select the date on which the task will be done.
  3. Once entered the above information, user will click on Add TODO button and the TODO
    text from the textbox will be added to the listbox shown on the bottom of the Windows
    Form.
  4. User can add as many items as he wants.
  5. If user has entered a task in June 10, 2013 - the item will NOT be shown on any other day
    except on the same day, i.e. June 10, 2013. So if user wants to see the TODO entered in
    June 04, user will select June 04 from the calendar and the tasks associated with that date
    will be displayed in the listbox. So listbox will contain tasks only from the selected date
    in calendar.
  6. Once the date selected to see the TODOs on that particular day, progress bar will show
    the progress based on the tasks completed VS tasks left. So for instance there are 100
    tasks, and 50 tasks have been completed then progress bar will show 50% completion and
    so on.
  7. Data must be stored persistently in a database, named TODODatabase. You need to think
    over the table schema yourself!

and this is what i have done so far... 1, 2, 3, 4, 5 and 7.. i am STUCK on number 6.. my progress bar works but it is not working according to the data selected in listbox.. here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace TODO
{
    public partial class Form1 : Form
    {
        int sum, no;
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'tODODataSet1.TODO' table. You can move, or remove it, as needed.
            this.tODOTableAdapter.Fill(this.tODODataSet1.TODO);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(textBox1.Text);
            //textBox1.Clear();
            //listBox1.Items.Add(dateTimePicker1.ToString());
            string connectionString = @"Data Source=sana\sqlexpress;Initial Catalog=TODO;Integrated Security=True";

            SqlConnection sqlCon = new SqlConnection(connectionString);
            sqlCon.Open();

            string commandString = "INSERT INTO TODO(items, Date) VALUES('" + textBox1.Text + "', '" + Convert.ToDateTime(this.dateTimePicker1.Value).ToString("MM/dd/yyyy") + "');";
            SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);

            int flag = sqlCmd.ExecuteNonQuery();
            if (flag == 1)
            {
                MessageBox.Show("Record inserted successfully!");
            }
            sqlCon.Close();
        }

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {

            string items;
            string connectionString = @"Data Source=sana\sqlexpress;Initial Catalog=TODO;Integrated Security=True";

            SqlConnection sqlCon = new SqlConnection(connectionString);
            sqlCon.Open();

            string commandString = "SELECT items FROM TODO WHERE Date = '"+Convert.ToDateTime(this.dateTimePicker2.Value).ToString("MM/dd/yyyy") + "'";
            SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);

            SqlDataReader read = sqlCmd.ExecuteReader();
            listBox1.Items.Clear();
            while (read.Read())
            {
                items = read["items"].ToString();
                listBox1.Items.Add(items);

                no = listBox1.Items.Count;

                sum = no / no * 100;
                progressBar1.Value = sum;

            }
            sqlCon.Close();
        }

        private void listBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 10)
            {
                int se;
                se = listBox1.SelectedIndex;
                listBox1.Items.RemoveAt(se);


            }

            no = listBox1.Items.Count;
            sum = no / no * 100;
            progressBar1.Value = sum;
        }
        }
    }

any help will be highly appreciated.

Change line 95 to progressBar1.Value = listBox1.Items.Count;
progressBar1.Maximum should be set to the total numbers of tasks somewhere.

thank you!

Glad to be of help, so mark this as solved.

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.