1, when the List<t> object is bound to the DataGridView data Source property, the content of the data source is not updated dynamically, and if the data in the List<t> object collection changes, the data source of the control will not be updated.
It is generally not recommended to use list<t> to populate the data source of the data display control.
If you must use the List<t> object to bind the data source, first set the DataGridView DataSource property to New List<t> (), and then list<t> The collection is re-assigned to the DataSource property. This resolves both the synchronization update issue.
When the DataGridView datasource is bound to a DataTable, when the contents of the DataTable change, the contents of DataGridView automatically follow the DataTable without rebinding the data source ; (Note: You cannot set the DataSource property of DataGridView to NULL, otherwise the column structure already set in DataGridView is broken.) 2, data binding after the addition of the deletion problem: If you want to bind in the DataGridView in the list<t> to add the deletion of data, the first to convert list<t> to Bindinglist<t> Bind again: Datagridview1.datasource=new bindinglist<myclass> (New list<myclass> ()). Otherwise, there will be many unexpected mistakes. such as: After the initial binding of the empty data after the addition of data binding, but the Datagridview.currentcell property is not taken.
list<urllistobject> rltlist = new list<urllistobject> (); rltlist = this. Analysishtml ();d atagridview1.datasource = new bindinglist<urllistobject> (rltlist);//Modify the data and refresh the foreach ( Urllistobject per_o in Rltlist) { Per_o.finalurl = Baseobjects.gettheredirecturl (Per_o.url); } This.dataGridView1.Refresh ();
WinForm programs use the list object to bind DataGridView data sources