protected void BindGrid() { BindingSource bindingSource1 = new BindingSource(); dataGridMatches.AutoGenerateColumns = false; dataGridMatches.ColumnCount = 7; dataGridMatches.Columns[0].Name = "Match Date"; dataGridMatches.Columns[0].DataPropertyName = "MatchDate"; dataGridMatches.Columns[1].Name = "Time"; dataGridMatches.Columns[1].DataPropertyName = "Time"; dataGridMatches.Columns[2].Name = "Home"; dataGridMatches.Columns[2].DataPropertyName = "Home"; dataGridMatches.Columns[3].Name = "Draw"; dataGridMatches.Columns[3].DataPropertyName = "Draw"; dataGridMatches.Columns[4].Name = "Away"; dataGridMatches.Columns[4].DataPropertyName = "Away"; dataGridMatches.Columns[5].Name = "ID"; dataGridMatches.Columns[5].DataPropertyName = "id"; dataGridMatches.Columns[5].Visible = false; var buttonCol = new DataGridViewButtonColumn(); buttonCol.UseColumnTextForButtonValue = true; buttonCol.Name = "Markets"; buttonCol.Text = "View Markets"; dataGridMatches.Columns.Add(buttonCol); //DataPropertyName = "BettingLink"; //dataGridMatches.Columns[4].DataPropertyName = "Away"; CrawlFirstPage crawl = new CrawlFirstPage(); bindingSource1.DataSource = crawl.GetMatchInfo(); dataGridMatches.DataSource = bindingSource1; //dataGridMatches. }
public void FillData2(string url, long id, long goflid, string bookies, int count) { OddsCheckerCrawler crawlcheck = MdiParent as OddsCheckerCrawler; try { CrawlEachMarket crawl = new CrawlEachMarket(); DataGridView dataGridView1 = new DataGridView(); DataTable dt = crawl.CrawlMarkets(url, id, goflid, bookies).Tables[0]; DataRow newrow = dt.NewRow(); dt.Rows.InsertAt(newrow, dt.Rows.Count); dataGridView1.DataSource = dt; dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; //dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; //dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; //dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True; dataGridView1.AllowUserToDeleteRows = false; dataGridView1.AllowUserToAddRows = false; dataGridView1.BackgroundColor = SystemColors.ControlLightLight; dataGridView1.BorderStyle = BorderStyle.None; dataGridView1.RowHeadersVisible = false; //dataGridView1.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCells); dataGridView1.CellDoubleClick += dataGridView1_CellDoubleClick; dataGridView1.DataBindingComplete += dataGridView1_DataBindingComplete; //dataGridView1.CellClick += dataGridView1_CellClick; dataGridView1.CellValueChanged += dataGridView1_CellValueChanged; //dataGridView1.Width = flowLayoutPanel1.Width - 30; dataGridView1.Name = Convert.ToString(id) + "," + Convert.ToString(goflid); // dataGridView1.Anchor = AnchorStyles.Bottom | AnchorStyles.Top; if (InvokeRequired) { Action a = () => { //if (!matchid.Equals(match_id)) if (!flowLayoutPanel1.Controls.ContainsKey(goflid.ToString())) { CrawlFirstPage crawlpage = new CrawlFirstPage(); DataTable dt1 = crawlpage.GetMatchInfo(goflid); GroupBox grpBox = new GroupBox(); string match = Convert.ToString(dt1.Rows[0]["Name"]) + " (" + Convert.ToString(dt1.Rows[0]["MatchDate"]) + ")"; grpBox.Text = match; grpBox.Name = goflid.ToString(); grpBox.AutoSize = true; FlowLayoutPanel flowpanel = new FlowLayoutPanel(); flowpanel.FlowDirection = FlowDirection.TopDown; flowpanel.Dock = DockStyle.Fill; flowpanel.WrapContents = false; flowpanel.AutoSize = true; flowpanel.Name = goflid.ToString() + goflid.ToString(); grpBox.Controls.Add(flowpanel); flowLayoutPanel1.Controls.Add(grpBox); grpBox.Anchor = AnchorStyles.Left | AnchorStyles.Right; //grpBox.Anchor = AnchorStyles.Left | AnchorStyles.Right; } FlowLayoutPanel panel = flowLayoutPanel1.Controls.Find(goflid.ToString() + goflid.ToString(), true).FirstOrDefault() as FlowLayoutPanel; panel.Controls.Add(dataGridView1); countthread++; if (countthread.Equals(count)) { crawlcheck.SetProgress(false); crawlcheck.IsProcessRunning = false; } }; BeginInvoke(a); } } catch (Exception ex) { if (InvokeRequired) { Action b = () => { crawlcheck.SetProgress(false); crawlcheck.IsProcessRunning = false; }; BeginInvoke(b); } } }