Exemple #1
0
        private void clientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmContacts frm = new frmContacts();

            frm.lblUser.Text     = User.Text;
            frm.lblUserType.Text = UserType.Text;

            frm.Show();
        }
        private void dataGridView2_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (SET.Text == "CS")
                {
                    DataGridViewRow dr = dataGridView2.SelectedRows[0];
                    this.Hide();
                    frmContacts frm = new frmContacts();
                    // or simply use column name instead of index
                    //dr.Cells["id"].Value.ToString();
                    frm.Show();
                    frm.txtID.Text         = dr.Cells[0].Value.ToString();
                    frm.txtName.Text       = dr.Cells[1].Value.ToString();
                    frm.txtmob.Text        = dr.Cells[2].Value.ToString();
                    frm.txtpostalcode.Text = dr.Cells[3].Value.ToString();
                    frm.txtCity.Text       = dr.Cells[4].Value.ToString();

                    frm.txtCountry.Text  = dr.Cells[5].Value.ToString();
                    frm.txtState.Text    = dr.Cells[6].Value.ToString();
                    frm.txtTitle.Text    = dr.Cells[7].Value.ToString();
                    frm.txtRole.Text     = dr.Cells[8].Value.ToString();
                    frm.txtNotes.Text    = dr.Cells[9].Value.ToString();
                    frm.txtcompany.Text  = dr.Cells[10].Value.ToString();
                    frm.lblUser.Text     = lblUser.Text;
                    frm.lblUserType.Text = lblUserType.Text;

                    frm.btnUpdate.Enabled = true;
                    frm.btnDelete.Enabled = true;
                    frm.btnNew.Enabled    = true;
                    frm.btnSave.Enabled   = false;
                    frm.txtName.Focus();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }