Three ways to display data on DataGridView

  • Query data from the database then loop through each record to assign it to DataGridView. Note that this method will slow down the display speed when the amount of data is large. Advice is not to use if not required.
  • Use Virtual mode of DataGridView. This way you only create enough lines to display and automatically change the content when the user scrolls.
  • Use databinding. This way is the simplest way. You just need to enter the data into the DataTable, then assign it to the DataGridView’s DataSource property. DataGridView can automatically create the corresponding Columns or you can create them manually by setting the DataPropertyName property for each column you want to display. It is suitable for cases where you have a large amount of data
Bài viết liên quan