private void toolStripTextBox1_TextChanged_1(object sender, EventArgs e)
        {
            panel1.Controls.Clear();
            dashboard_class dash = new dashboard_class();

            dash._title    = tstxt2.Text.ToString();
            dash._username = lblUsername.Text;
            string userid = dash.userIDD();

            dash._userid = userid;
            DataTable dt = dash.titleandcontent5();


            int x = 10, y = 50;
            int d = 1;
            int n = 0;

            for (int s = 0; s < dt.Rows.Count; s++)
            {
                Panel childPanel = new Panel();
                childPanel.Location  = new Point(x, y);
                childPanel.BackColor = Color.AliceBlue;
                childPanel.Size      = new Size(250, 250);
                Label lblid = new Label();
                lblid.Text     = dt.Rows[n][2].ToString();
                lblid.Location = new Point(10, 220);
                lblid.Visible  = true;
                Label lbltitle = new Label();
                lbltitle.Text     = dt.Rows[n][0].ToString();
                dash._title       = lbltitle.Text;
                lbltitle.Location = new Point(10, 10);

                TextBox txtcontent = new TextBox();
                txtcontent.Text      = dt.Rows[n][1].ToString();
                dash._content        = txtcontent.Text;
                txtcontent.Size      = new Size(200, 150);
                txtcontent.Location  = new Point(10, 40);
                txtcontent.Multiline = true;
                Button btnclick = new Button();
                btnclick.Text     = "DELETE";
                btnclick.Location = new Point(170, 200);
                n = n + 1;
                //inner click event
                btnclick.Click += (z, a) =>
                {
                    if (MessageBox.Show("Are you Sure you want to delete?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

                    {
                        dash._content = txtcontent.Text;
                        dash.deletesticky();
                        MessageBox.Show("Successfully Deleted");
                        panel1.Controls.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Not deleted!");
                    }
                };
                //adding to Child Panel
                childPanel.Controls.Add(lblid);
                childPanel.Controls.Add(lbltitle);
                childPanel.Controls.Add(txtcontent);
                childPanel.Controls.Add(btnclick);
                //adding child panel to parent panel
                panel1.Controls.Add(childPanel);
                x = x + childPanel.Width + 10;
                d = d + 1;
                if (x > 1300)
                {
                    x = 10;
                    y = y + childPanel.Width + 10;
                }
            }
        }
        private void toolStripTextBox1_TextChanged(object sender, EventArgs e)
        {
            panel1.Controls.Clear();
            dashboard_class dash = new dashboard_class();

            dash._title    = tstxt1.Text.ToString();
            dash._username = lblUsername.Text;
            string userid = dash.userIDD();

            dash._userid = userid;
            DataTable dt = dash.titleandcontent5();


            int x = 10, y = 50;
            int d = 1;
            int n = 0;

            for (int s = 0; s < dt.Rows.Count; s++)
            {
                Panel childPanel = new Panel();
                childPanel.Location  = new Point(x, y);
                childPanel.BackColor = Color.AliceBlue;
                childPanel.Size      = new Size(250, 250);
                Label lblid = new Label();
                lblid.Text     = dt.Rows[n][2].ToString();;
                lblid.Location = new Point(10, 220);
                lblid.Visible  = true;
                Label lbltitle = new Label();
                lbltitle.Text = dt.Rows[n][0].ToString();

                lbltitle.Location = new Point(10, 10);
                ComboBox cmbcategory = new ComboBox();
                dash._stickyid = int.Parse(lblid.Text);
                DataTable dt1 = dash.getcategory();
                DataTable dt2 = dash.getcategory1();

                for (int i = 0; i < dt2.Rows.Count; i++)

                {
                    DataRow dataRow = dt1.NewRow();
                    dataRow["Categories_Name"] = dt2.Rows[i][1].ToString();
                    dataRow["Categories_ID"]   = dt2.Rows[i][0].ToString();
                    dt1.Rows.Add(dataRow);
                }


                cmbcategory.DataSource    = dt1;
                cmbcategory.DisplayMember = "Categories_Name";

                cmbcategory.ValueMember = "Categories_ID";
                cmbcategory.Location    = new Point(120, 10);
                TextBox txtcontent = new TextBox();
                txtcontent.Text = dt.Rows[n][1].ToString();


                txtcontent.Size      = new Size(200, 150);
                txtcontent.Location  = new Point(10, 40);
                txtcontent.Multiline = true;
                Button btnclick = new Button();
                btnclick.Text     = "SAVE";
                btnclick.Location = new Point(170, 200);
                n = n + 1;
                //inner click event
                btnclick.Click += (z, a) =>
                {
                    if (MessageBox.Show("Are you Sure you want to Save?", "SAVE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

                    {
                        dash._categoryid = int.Parse(cmbcategory.SelectedValue.ToString());
                        dash._title      = lbltitle.Text;
                        dash._content    = txtcontent.Text;
                        dash.updateContent();
                        MessageBox.Show("Successfully saved");
                        panel1.Controls.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Not Updated!");
                    }
                };
                //adding to Child Panel
                childPanel.Controls.Add(lblid);
                childPanel.Controls.Add(lbltitle);
                childPanel.Controls.Add(cmbcategory);
                childPanel.Controls.Add(txtcontent);
                childPanel.Controls.Add(btnclick);
                //adding child panel to parent panel
                panel1.Controls.Add(childPanel);
                x = x + childPanel.Width + 10;
                d = d + 1;
                if (x > 1300)
                {
                    x = 10;
                    y = y + childPanel.Width + 10;
                }
            }
        }