I have a database(opos)which contains a table (unpaidchecks). I want to first all check if the data contains data and if it does I want to loop through it and compare the data from one of the columns (user) to libuser. Text , then if it’s the same I creat a dynamic button. The buttons are supposed to be created when the form loads
- loads unpaidcheck uk = new unpaidcheck();
- oposEntities gg = new oposEntities();
- private void Interface_Load(object sender, EventArgs e) {
- int i = 0;
- int x = 0;
- if (gg.unpaidchecks.Count() != 0) {
- foreach(DataRow item in gg.uk. {
- if (uk.user.Contains(this.libuser.Text)) {
- Button btn = new Button();
- btn.Location = new Point(3 + i, 14 + x);
- btn.Width = 160;
- btn.Height = 80;
- btn.BackColor = System.Drawing.Color.Red;
- btn.ForeColor = System.Drawing.Color.Yellow;
- btn.Text = "Tabel" + item["tabel_no_"].ToString();
- btn.Click += new EventHandler(btn_Click);
- this.panel3.Controls.Add(btn);
- i += 10;
- x += 10;
- }
- }