HY
I HAVE PROGRESSBAR NOT WITH PERCENT JUST WITH STYLE :Marquee
in click event i exec stored procedure into datagridview
but when i click the button and write :MarqueeAnimationSpeed =30
and after exec the sp the pb doesnt animated
as i know i need to make thread but i dont no how?
pls help me

this.Cursor = Cursors.WaitCursor;
                progressBar1.MarqueeAnimationSpeed = 30;



                string kindOfReport;
                string connectionstrinng;
                string connectionstring_OLTP01;
                string strSqlDel;





                connectionstrinng = ConfigurationManager.AppSettings["CONN"];// "Data Source=xxx;Initial Catalog=xxx;Integrated Security=True";
                SqlConnection connImportVed = new SqlConnection(connectionstrinng);

To start:

progressBar1.Style = ProgressBarStyle.Marquee;
progressBar1.MarqueeAnimationSpeed = 30;
progressBar1.Visible = true;

To stop:

progressBar1.Visible = false;

Additionally, to stop it, you could add:

progressBar1.Style = ProgressBarStyle.Continuous;
progressBar1.MarqueeAnimationSpeed = 0;

Although, it is probably unnecessary.

You have to change progress bar first, you can make this in Properties tab or can program it:
progressBar1.Style = ProgressBarStyle.Marquee
Good luck;

hy because iths 2 process at one i cant see the progressbar!
as i saw i need to put thread

hy because its 2 process at same time i cant see the progressbar!
as i saw i need to put thread to one of them
and i dont know how! thanks@@@

You haven't posted enough of your code to really know what you are trying to do.

hy this the code
the code execute sp and put the data on datagridview
the problem is when i click the progressbar stopped because there is 2 thread : sp exec + pb
i want to put the sp in another thread because i want that the progressbar will work
this is fullcode of b

       private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {


                if (lstCatTo.Items.Count == 0)
                {

                    throw new Exception();

                }


                if (Convert.ToDateTime(cmbToDate.Text) <= Convert.ToDateTime(cmbFromDate.Text))
                {
                    throw new Exception();

                }

                if (cmbReportType.Text.Trim().Length == 0)
                {

                    throw new Exception();

                }
                progressBar1.Style = ProgressBarStyle.Marquee;
                progressBar1.MarqueeAnimationSpeed = 30;
                progressBar1.Visible = true;

               // button1.Enabled = true;
                // StartProgressBar(progressBar1);


                string kindOfReport;
                string connectionstrinng;
                string connectionstring_OLTP01;
                string strSqlDel;




               // lblWait.Enabled = true;
               // lblWait.Visible = true;

                this.Cursor = Cursors.WaitCursor;

                connectionstrinng = ConfigurationManager.AppSettings["TLVWINRIP001_CONN"];// "Data Source=TLVWINRIP001;Initial Catalog=ImportVed;Integrated Security=True";
                SqlConnection connImportVed = new SqlConnection(connectionstrinng);


                connectionstring_OLTP01 = ConfigurationManager.AppSettings["OLTP01_CONN"];// "Data Source=ACN972-OLTP01;Initial Catalog=ConsumerPanel;Integrated Security=True";
                SqlConnection connConsumerPanel = new SqlConnection(connectionstring_OLTP01);



                //insert data to tempcat
                //StringBuilder sb = new StringBuilder();
                // string getCategory = string.Empty;

                SqlCommand cmd;
                SqlCommand cmdDel;
                SqlCommand cmdDel_oltp01;
                SqlCommand cmdDelete;

                //delete table from tlvwinrip001
                strSqlDel = "delete from tempcat";
                cmdDel = new SqlCommand(strSqlDel);
                connImportVed.Open();
                cmdDel.Connection = connImportVed;
                cmdDel.ExecuteNonQuery();

                //delete table from oltp01
                cmdDel_oltp01 = new SqlCommand(strSqlDel);
                connConsumerPanel.Open();
                cmdDel_oltp01.Connection = connConsumerPanel;
                cmdDel_oltp01.ExecuteNonQuery();



                for (int z = 0; z < lstCatTo.Items.Count; z++)
                {
                    string tmpCategory;
                    string strSql;
                    tmpCategory = (string)lstCatTo.Items[z];
                    tmpCategory = tmpCategory.Replace(" ", "");
                    strSql = "Insert into tempcat select '" + tmpCategory + "'";
                    cmd = new SqlCommand(strSql);
                    cmd.Connection = connImportVed;
                    cmd.ExecuteNonQuery();
                }

                for (int z = 0; z < lstCatTo.Items.Count; z++)
                {
                    string tmpCategory;
                    string strSql;
                    tmpCategory = (string)lstCatTo.Items[z];
                    tmpCategory = tmpCategory.Replace(" ", "");
                    strSql = "Insert into tempcat select '" + tmpCategory + "'";
                    cmd = new SqlCommand(strSql);
                    cmd.Connection = connConsumerPanel;
                    cmd.ExecuteNonQuery();
                }

                //first we need to execute cps - oltp01
                ///////////////////////////////////////////////////////////////////////////////////////////
                ///first delete tmp_cps table from consumerPanel
                ///////////////////////////////////////////////////////////////////////////////////////////
                string strSqlDelete;
                strSqlDelete = "delete from TMP_CPS";
                cmdDelete = new SqlCommand(strSqlDelete);
                cmdDelete.Connection = connConsumerPanel;
                cmdDelete.ExecuteNonQuery();
                //////////////////////////////////////////////////////////////////////////////////////////////
                SqlCommand Storproc_oltp = new SqlCommand();
                Storproc_oltp.Connection = connConsumerPanel;
                Storproc_oltp.CommandType = CommandType.StoredProcedure;
                Storproc_oltp.CommandText = "GETcpsP_codes";
                DateTime newDateFrom = Convert.ToDateTime(cmbFromDate.Text);
                DateTime newDateTo = Convert.ToDateTime(cmbToDate.Text);
                Storproc_oltp.Parameters.AddWithValue("@efromDate", newDateFrom);
                Storproc_oltp.Parameters.AddWithValue("@etoDate", newDateTo);
                Storproc_oltp.CommandTimeout = 10000;
                Storproc_oltp.ExecuteNonQuery();
                //now the data in table CPS_TBL in oltp01
                //aplied data from oltp01 to tlvwinrip001
                ////////////////////////////////////////////////////////////////////////////////////////////

                SqlCommand Storproc_oltpToRip = new SqlCommand();
                Storproc_oltpToRip.Connection = connImportVed;
                Storproc_oltpToRip.CommandType = CommandType.StoredProcedure;
                Storproc_oltpToRip.CommandText = "inserDataFromOLTP_toRIP";
                Storproc_oltpToRip.Parameters.AddWithValue("@fromDate", newDateFrom);
                Storproc_oltpToRip.Parameters.AddWithValue("@toDate", newDateTo);
                Storproc_oltpToRip.CommandTimeout = 10000;
                Storproc_oltpToRip.ExecuteNonQuery();

                /////////////////////////////////////////////////////////////////////////////////////////////
                SqlCommand Storproc = new SqlCommand();
                Storproc.Connection = connImportVed;
                Storproc.CommandType = CommandType.StoredProcedure;
                Storproc.CommandText = "CreateCatalogeRMS_Finall";
                /// no we need to call to sp with parameter and put data in data grid view

                ///DateTime newDateFrom = Convert.ToDateTime(cmbFromDate.Text);
                /// DateTime newDateTo = Convert.ToDateTime(cmbToDate.Text);
                Storproc.Parameters.AddWithValue("@efromDate", newDateFrom);
                Storproc.Parameters.AddWithValue("@etoDate", newDateTo);
                /////////////////////////////////////////////////////////////////////////////////////////////
                SqlCommand StorprocHebEng = new SqlCommand();
                StorprocHebEng.Connection = connImportVed;
                StorprocHebEng.CommandType = CommandType.StoredProcedure;
                StorprocHebEng.CommandText = "getHebAndENG";
                StorprocHebEng.Parameters.AddWithValue("@efromDate", newDateFrom);
                StorprocHebEng.Parameters.AddWithValue("@etoDate", newDateTo);
                ////////////////////////////////////////////////////////////////////////////////////////////


                kindOfReport = cmbReportType.GetItemText(cmbReportType.SelectedItem);
                if (kindOfReport == "עברית") //עברית
                {

                    Storproc.Parameters.AddWithValue("@KINDOFREPORT", 0);

                }
                if (kindOfReport == "אנגלית")//אנגלית
                {
                    Storproc.Parameters.AddWithValue("@KINDOFREPORT", 1);

                }
                if (kindOfReport == "משולב")//משולב
                {
                    Storproc.Parameters.AddWithValue("@KINDOFREPORT", 2);

                }
                if (kindOfReport == "עברית ואנגלית")//עברית אחרי אנגלית
                {
                    StorprocHebEng.Parameters.AddWithValue("@KINDOFREPORT", 3);
                    StorprocHebEng.Parameters.AddWithValue("@ENG_OR_HEB", 1);
                    StorprocHebEng.CommandTimeout = 10000;
                    StorprocHebEng.ExecuteNonQuery();
                    DataTable dttt = new DataTable();
                    SqlDataAdapter daa = new SqlDataAdapter();
                    daa.SelectCommand = StorprocHebEng;
                    daa.Fill(dttt);
                    dvRMS.DataSource = dttt;
                    return;
                }
                Storproc.CommandTimeout = 10000;
                Storproc.ExecuteNonQuery();
                DataTable dtt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = Storproc;
                da.Fill(dtt);
                dvRMS.DataSource = dtt;
                //progressBar1.MarqueeAnimationSpeed = 0;
                lblWait.Visible = false;
                this.Cursor = Cursors.Default;
            }

            catch (System.Exception excep)
            {

                if (cmbFromDate.Text.Trim().Length == 0)
                {
                    MessageBox.Show("יש לבחור  תאריך התחלה",
                "קטלוג משולב",
                MessageBoxButtons.OK,
                MessageBoxIcon.Exclamation,
                MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;
                }
                else if (cmbToDate.Text.Trim().Length == 0)
                {
                    MessageBox.Show("יש לבחור  תאריך סיום",
                    "קטלוג משולב",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;
                }
                else if (Convert.ToDateTime(cmbToDate.Text) <= Convert.ToDateTime(cmbFromDate.Text))
                {
                    MessageBox.Show("ת.סיום קטן שווה לת.התחלה",
                      "קטלוג משולב",
                      MessageBoxButtons.OK,
                      MessageBoxIcon.Exclamation,
                      MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;

                }

                else if (cmbReportType.Text.Trim().Length == 0)
                {
                    MessageBox.Show("יש לבחור סוג דוח",
                    "קטלוג משולב",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;

                }
                else if (lstCatTo.Items.Count == 0)
                {

                    MessageBox.Show("יש לבחור קטגוריית בסיס ",
                    "קטלוג משולב",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;
                }

                else
                {
                    MessageBox.Show(excep.Message,
                    "קטלוג משולב",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button1);
                    this.Cursor = Cursors.Default;
                    return;
                }
            }

uttonclick

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.