private void get_controls(SplitContainer SC) { foreach (Control c in SC.Panel1.Controls) { if (c is ComboBox) { cbb = (c as ComboBox); } if (c is Label) { lbl = (c as Label); } } foreach (Control c in SC.Panel2.Controls) { if (c is MultiColumnComboBox) { mcbb = (c as MultiColumnComboBox); } if (c is Label && c.Text != "X") { llbl = (c as Label); } } }
private void lees_stnd() { stand = 1; btn_del.Hide(); btn_add.Hide(); if (deleting) { EventArgs e = new EventArgs(); btn_del_Click(this, e); } for (int i = 0; i < num_rows; i++) { SplitContainer SC = SC_ar[i]; // SC.Location = new Point(SC.Location.X, SC.Location.Y - 33); foreach (Control c in SC.Panel2.Controls) { if (c is MultiColumnComboBox) { mcbb = (c as MultiColumnComboBox); c.Hide(); } else if (c is Label && c.Text != "X") { llbl = (c as Label); c.Show(); } else if (c is Label) { c.Hide(); } } foreach (Control c in SC.Panel1.Controls) { if (c is ComboBox) { cbb = (c as ComboBox); c.Hide(); } else if (c is Label) { lbl = (c as Label); c.Show(); } } if (!init_lbl) { if (mcbb.SelectedIndex > 0) { DataRowView drv = (DataRowView)mcbb.SelectedItem; if (type == 2) { llbl.Text = drv.Row.ItemArray[4].ToString(); } else if (type == 3) { llbl.Text = drv.Row.ItemArray[2].ToString(); } } lbl.Text = cbb.Text; } } }
private void add_controls(SplitContainer SC, int cbbint, int mcbbint) { ComboBox cb1 = new ComboBox(); cb1.Location = new Point(6, 2); MultiColumnComboBox mcb2 = new MultiColumnComboBox(); mcb2.Location = new Point(6, 2); mcb2.Size = new Size(235, 21); mcb2.AutoComplete = true; mcb2.AutoCompleteMode = AutoCompleteMode.SuggestAppend; mcb2.AutoDropdown = true; mcb2.DropDownHeight = 106; mcb2.DropDownWidth = 235; if (type == 2)//bedrijf { mcb2.ColumnWidths = "0;200;0;100;0"; mcb2.BindingContext = new BindingContext(); mcb2.DataSource = bdr_dt_table; mcb2.DisplayMember = "zoeknaam"; mcb2.ValueMember = "bedrijf_nr"; mcb2.SelectedIndex = -1; cb1.BindingContext = new BindingContext(); cb1.DataSource = bdr_var_funct_table; cb1.DisplayMember = "naam"; cb1.ValueMember = "functie_ID"; cb1.SelectedIndex = -1; } else if (type == 3)//contact { mcb2.ColumnWidths = "0;200;0;200"; mcb2.BindingContext = new BindingContext(); mcb2.DataSource = pers_dt_table; mcb2.DisplayMember = "SearchName"; mcb2.ValueMember = "persoon_nr"; mcb2.SelectedIndex = -1; cb1.BindingContext = new BindingContext(); cb1.DataSource = pers_var_funct_table; cb1.DisplayMember = "naam"; cb1.ValueMember = "functie_ID"; cb1.SelectedIndex = -1; } Label lbl1 = new Label(); lbl1.Location = new Point(6, 6); lbl1.AutoSize = true; lbl1.AutoEllipsis = true; Label lbl2 = new Label(); lbl2.AutoSize = true; lbl2.Location = new Point(6, 6); if (cbbint < 0 && mcbbint < 0) { init_lbl = true; lbl2.Text = "nog niet toegekent"; lbl1.Text = "nog niet toegekent"; } else { init_lbl = false; foreach (DataRow dr in ((DataTable)mcb2.DataSource).Rows) { if (type == 2) { if ((int)dr["bedrijf_nr"] == mcbbint) { mcb2.SelectedValue = mcbbint; DataRowView drv = (DataRowView)mcb2.SelectedItem; lbl2.Text = drv.Row.ItemArray[4].ToString(); } } else if (type == 3) { if ((int)dr["persoon_nr"] == mcbbint) { mcb2.SelectedValue = mcbbint; DataRowView drv = (DataRowView)mcb2.SelectedItem; lbl2.Text = drv.Row.ItemArray[2].ToString(); } } } foreach (DataRow dr2 in ((DataTable)cb1.DataSource).Rows) { if ((int)dr2["functie_ID"] == cbbint) { cb1.SelectedValue = cbbint; lbl1.Text = cb1.Text; } } } Button btn = new Button(); btn.TabStop = false; btn.Image = Properties.Resources.new_pijl; btn.Location = new Point(246, 1); btn.Text = ""; btn.Size = new Size(21, 21); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderSize = 0; btn.Click += new EventHandler(btn_Click); btn.MouseEnter += new EventHandler(btn_MouseEnter); btn.MouseLeave += new EventHandler(btn_MouseLeave); Label del_lbl = new Label(); del_lbl.Click += new System.EventHandler(this.del_Click); del_lbl.Location = new Point(246, 3); del_lbl.Text = "X"; del_lbl.ForeColor = Color.DarkGray; del_lbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 12, FontStyle.Bold); SC.Panel1.Controls.Add(cb1); SC.Panel2.Controls.Add(mcb2); SC.Panel1.Controls.Add(lbl1); SC.Panel2.Controls.Add(lbl2); SC.Panel2.Controls.Add(btn); SC.Panel2.Controls.Add(del_lbl); }