Example #1
0
        private void DataGridViewUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewUsers.Rows[e.RowIndex].Selected = true;                                                    //koji je retka je kliknut, klikom na gumbic u odredenom retku taj redat bude selektiran, redak se zaplavi n stuff
            if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(5) && e.RowIndex != -1)                           //ako je index trenutne celije jednak 5(broj kolona,krece od  0) i ako index retka nije -1 onda ide radnja
            {
                FormEditUser FormEditUser = new FormEditUser(this);                                                //kreiraj novu formu yo;this salje sam sebe drugoj formi, this je objekt prve forme
                FormEditUser.lblEditUserID.Text    = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString(); //upuca text u labelu iz pritisnutog retka
                FormEditUser.lblEditUsername.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
                FormEditUser.inptEditPassword.Text = DataGridViewUsers.Rows[e.RowIndex].Cells[2].Value.ToString();
                FormEditUser.inptEditName.Text     = DataGridViewUsers.Rows[e.RowIndex].Cells[3].Value.ToString();
                FormEditUser.inptEditSurname.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[4].Value.ToString();
                FormEditUser.Show();//prikazi formu yo
            }

            if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(6) && e.RowIndex != -1)
            {
                FormDeleteUser FormDeleteUser = new FormDeleteUser(this);
                FormDeleteUser.ID       = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
                FormDeleteUser.Username = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
                FormDeleteUser.Password = DataGridViewUsers.Rows[e.RowIndex].Cells[2].Value.ToString();
                FormDeleteUser.Name     = DataGridViewUsers.Rows[e.RowIndex].Cells[3].Value.ToString();
                FormDeleteUser.Surname  = DataGridViewUsers.Rows[e.RowIndex].Cells[4].Value.ToString();
                FormDeleteUser.Show();
            }
        }
Example #2
0
        private void DataGridViewUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //metoda za provjeravanje da li se poziva funkcija klikom na gumb
            //MessageBox.Show("Dot Net");

            DataGridViewUsers.Rows[e.RowIndex].Selected = true; //tu se postavlja da se redak zaplavi

            //ako je index kliknute ćelije (kolone) 5 i index retka različit od -1, napravi nešto
            if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(5) && e.RowIndex != -1)
            {
                //Form1 FormUserList=this;
                FormEditUser FormEditUser = new FormEditUser(this);  //kreiran novi objekt druge forme(edit user) - this-pokazivač na objekt prve forme
                //new FormEditUser(this ) -objekt klase formedituser čiji konstruktor zaprima objekt klase formedituser
                FormEditUser.lblEditUserID.Text = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
                //iz dataviewgrid kontrole edituserid iz reda koji je pritisnut i ćelije
                //objekti kojima mijenjamo vrijednost moraju biti u formi2.designer postavljeni kao public (po defaultu je private)
                FormEditUser.lblEditUserName.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
                FormEditUser.inptEditPassword.Text = DataGridViewUsers.Rows[e.RowIndex].Cells[2].Value.ToString();
                FormEditUser.inptEditName.Text     = DataGridViewUsers.Rows[e.RowIndex].Cells[3].Value.ToString();
                FormEditUser.inptEditSurname.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[4].Value.ToString();
                FormEditUser.Show();
            }

            if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(6) && e.RowIndex != -1)
            {
                //Form1 FormUserList=this;
                FormDeleteUser FormDeleteUser = new FormDeleteUser(this); //kreiran novi objekt druge forme(edit user) - this-pokazivač na objekt prve forme
                //new FormEditUser(this ) -objekt klase formedituser čiji konstruktor zaprima objekt klase formedituser
                FormDeleteUser.lblDeleteuserID.Text = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
                FormDeleteUser.ID = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
                FormDeleteUser.Show();
            }
        }
Example #3
0
 private void DataGridViewUsers_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     DataGridViewUsers.Rows[e.RowIndex].Selected = true;
     if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(5) && e.RowIndex != -1)
     {
         FormEditUser FormEditUser = new FormEditUser(this);
         FormEditUser.lblEditUserID.Text    = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
         FormEditUser.lblEditUserName.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
         FormEditUser.inptEditPassword.Text = DataGridViewUsers.Rows[e.RowIndex].Cells[2].Value.ToString();
         FormEditUser.inptEditName.Text     = DataGridViewUsers.Rows[e.RowIndex].Cells[3].Value.ToString();
         FormEditUser.inptEditSurname.Text  = DataGridViewUsers.Rows[e.RowIndex].Cells[4].Value.ToString();
         FormEditUser.Show();
     }
     if (DataGridViewUsers.CurrentCell.ColumnIndex.Equals(6) && e.RowIndex != -1)
     {
         FormDeleteUser FormDeleteUser = new FormDeleteUser(this);
         FormDeleteUser.nID       = DataGridViewUsers.Rows[e.RowIndex].Cells[0].Value.ToString();
         FormDeleteUser.sName     = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
         FormDeleteUser.sSurname  = DataGridViewUsers.Rows[e.RowIndex].Cells[1].Value.ToString();
         FormDeleteUser.sPassword = DataGridViewUsers.Rows[e.RowIndex].Cells[2].Value.ToString();
         FormDeleteUser.sUsername = DataGridViewUsers.Rows[e.RowIndex].Cells[3].Value.ToString();
         FormDeleteUser.Show();
     }
 }