Example #1
0
        //this is theclick event that checks for the buttons and then opens the respective form
        private void dgvClients_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == dgvClients.Columns["View"].Index)
                {
                    int IDtoPass = int.Parse(dgvClients.Rows[e.RowIndex].Cells[e.ColumnIndex + 2].Value.ToString());//gets the ID

                    ClientView form = new ClientView(IDtoPass);
                    form.ShowDialog();
                }
                else if (e.ColumnIndex == dgvClients.Columns["Invoices"].Index)
                {
                    int IDtoPass = int.Parse(dgvClients.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString());//gets the ID

                    Invoices form = new Invoices(IDtoPass);
                    form.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("You tried to click the button that was not in a row with data. \n This is the error: " + ex.Message);
            }
        }
Example #2
0
        private void btnClientView_Click(object sender, EventArgs e)
        {
            ClientView form = new ClientView();

            form.ShowDialog();
        }