Exemplo n.º 1
0
        private void PopulateAccountRows(int categoryId)
        {
            dgvShed.Rows.Clear();

            foreach (var account in AccountService.GetAccountsByCategoryId(categoryId))
            {
                var accountRow = new DataGridViewRow {
                    Tag = account.Id
                };

                var credentialsInAccount = CredentialService.GetCredentialsByAccountId(account.Id);

                foreach (DataGridViewColumn column in dgvShed.Columns)
                {
                    Credential credential = credentialsInAccount.SingleOrDefault(c => c.FieldId == (int)column.Tag);

                    accountRow.Cells.Add(
                        new DataGridViewTextBoxCell {
                        Value = credential.Value, Tag = credential.Id, MaxInputLength = 99
                    });
                }

                dgvShed.Rows.Add(accountRow);
            }
        }