January 23, 2016

Displaying data from Database to comboBox in C#

private void GetMachine()
        {
            SqlDataAdapter d = new SqlDataAdapter("select * from machine", con);
            DataTable dt = new DataTable();
            d.Fill(dt);
            cmbMachineType.DataSource = dt;
            cmbMachineType.DisplayMember = "machinetype";
        }

Designing a welcome screen in C#.net

Controls needed 

1. Progress bar
2. Timer control

Set the Maximum property of Progress bar to 110

and on timer1_Tick. Use the following code


private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Value = progressBar1.Value + 10;
            if (progressBar1.Value == 110)
            {
                timer1.Enabled = false;
                Login frm2 = new Login();
                frm2.FormClosed += new FormClosedEventHandler(frm2_FormClosed);
                frm2.Show();
                this.Hide();
            }
        } 


To close the parient form from child form use FormClosedEventHandler

 private void frm2_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Close();
        }

January 21, 2016

Welcome 2016

fdsds