private void SelectCategoryForm_Load(object sender, EventArgs e) { scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter(); cdt = cta.GetDataOrderByNome(); if (cdt.Count == 0) { MessageBox.Show("Non è stata ancora definita alcuna categoria.", "Nessuna categoria presente", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); return; } else { for (int i = 0; i < cdt.Count; i++) { CategoryCheckbox cbx = new CategoryCheckbox(); cbx.Text = cdt[i]["Nome"].ToString(); cbx.IdCategoria = int.Parse(cdt[i]["ID"].ToString()); if (selectedCategory.Contains(cbx.IdCategoria)) cbx.Checked = true; else cbx.Checked = false; cbx.Size = new Size(250, 20); flowLayoutPanel.Controls.Add(cbx); } } }
private void loadCategorieMovimento() { //carico le categorie precedentemente assegnate nella lista categories = new List<int>(); scadenzettiDbDataSetTableAdapters.CategoriaMovimentoTableAdapter cmta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaMovimentoTableAdapter(); cmdt = cmta.GetDataByMovimento(idMov); for (int i = 0; i < cmdt.Count; i++) { categories.Add(int.Parse(cmdt[i]["Categoria"].ToString())); } //elenco tutte le categorie scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter cta = new Scadenzetti.scadenzettiDbDataSetTableAdapters.CategoriaTableAdapter(); cdt = cta.GetDataOrderByNome(); for (int j = 0; j < cdt.Count; j++) { CategoryCheckbox catcbx = new CategoryCheckbox(); catcbx.AutoSize = true; catcbx.IdCategoria = int.Parse(cdt[j]["ID"].ToString()); catcbx.Text = cdt[j]["Nome"].ToString(); if (categories.Contains(catcbx.IdCategoria)) catcbx.Checked = true; else catcbx.Checked = false; flowLayoutPanel.Controls.Add(catcbx); } }