Weeman Osekre

Weeman Osekre

  • NA
  • 56
  • 3.5k

Grouping table data

Nov 4 2020 9:57 AM
I have data in my table and some have the same data on one of the columns ( tabel_no_) . I want to group all the table_no_ that have the same number and create a dynamic button for it . The problem with this code is item doesn’t accept Groupby private void Interface_Load(object sender, EventArgs e){int i = 0;int x = 0;if (gg.unpaidchecks.Count() != 0){foreach(var item in gg.unpaidchecks.ToList()){ item.GroupBy(p => p.tabel_no_).Select(group => new { Key = group.Key, item = group.OrderByDescending(s => s.date) }).Select(g => g.item.First());if (item.user == 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.flowLayout5.Controls.Add(btn);i += 10;x += 10;

Answers (3)