public void LoadAllTables() { try { dataGridView1.DataSource = objMenuCatogeryServicel.GetAllMenuCatogery(); dataGridView1.Columns[2].Visible = false; for (int i = 0; i < dataGridView1.Rows.Count; i++) { dataGridView1.Rows[i].Cells[4].Style.BackColor = System.Drawing.ColorTranslator.FromHtml(dataGridView1.Rows[i].Cells[4].Value.ToString()); dataGridView1.Rows[i].Cells[4].Style.ForeColor = System.Drawing.ColorTranslator.FromHtml(dataGridView1.Rows[i].Cells[4].Value.ToString()); } } catch (Exception exp) { MessageBox.Show(exp.Message, "Exception Error"); } }
private void AddMenuItems_Load(object sender, EventArgs e) { try { LoadAllTables(); ComboBoxCategory.DataSource = objMenuCatogeryServicel.GetAllMenuCatogery(); ComboBoxCategory.ValueMember = "id"; ComboBoxCategory.DisplayMember = "name"; catogeryName = ComboBoxCategory.SelectedText; ComboBoxSection.DataSource = objCounterServicel.GetAllCounters(); ComboBoxSection.ValueMember = "id"; ComboBoxSection.DisplayMember = "sectionname"; sectionName = ComboBoxSection.SelectedText; } catch (Exception exp) { MessageBox.Show(exp.Message, "Exception Error In Loading Form"); } }