Hi sanjaypakale,
Yes, you are right. We can handle the Scroll event of the DataGridView to add columns or rows. We need to pay attentions to the items below:
1. Check the count of the columns/rows. We need to restrict the count of the rows/columns so that the adding process can end when we approach to a maximum value. Otherwise, the adding process cannot be stopped and would cause a freeze of the program.
2. When we add a row, we have different ways according to whether the DataGridView is bound or not. If the DataGridView is unbound, we can directly call the Add method of the Rows property of the DataGridView. If it is bound, we need to get the underlying data source and add a row via that object. For example, if the data source if of type DataTable, we can follow the code below to add a row:
DataTable dt = this.dataGridView1.DataSource as DataTable;
dt.Rows.Add(dt.NewRow());
Let me know if this helps.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.