Wednesday, 9 March 2016

select a complete dataGridView Row when the user clicks a cell

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            int index = e.RowIndex;
            dataGridView1.Rows[index].Selected = true;
        }

Notification in C#

the following control will be added (notiyicon) to the application:



 Add the following code to the form:

                             notifyIcon1.Text = "Notification";
                            notifyIcon1.Visible = true;
                            notifyIcon1.BalloonTipTitle = "You Have  Application Pending ";
                            notifyIcon1.BalloonTipText = "Click Here to see details";

                            notifyIcon1.ShowBalloonTip(100);

Tuesday, 8 March 2016

How to check Testbox is empty or not

 if (Textbox.Text != "")
{
Do Somting Here.
}

Change Date Formate

String Date=Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd");

Fill Combobox From DataBase in C#


            MySqlCommand cmd = new MySqlCommand("select * from tbl_categorie", con.getcon());
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            cmb_categorie.DataSource = dt;
            cmb_categorie.ValueMember = "Ctegory_Id";
            cmb_categorie.DisplayMember = "categorie";

Fill Combobox From DatBase In c#


            MySqlCommand cmd = new MySqlCommand("select * from tbl_categorie", con.getcon());
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            cmb_categorie.DataSource = dt;
            cmb_categorie.ValueMember = "Ctegory_Id";
            cmb_categorie.DisplayMember = "categorie";
            

Count dataGridView Row Count

 int count = dataGridView1.Rows.Count - 1;