Hi kana250688,
You need to make use of AutoSizeColumnsMode property of DataGridView and set it to DisplayedCells as shown below.
refer below code.
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells
This ensures that Columns are resized based on currently displayed cells.
If you use like below
DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells)
It will count those cells which are not displayed after filtering the data.
After setting this property the slow typing of TextBox will be solved too as no more time is consuming to filter the data or resizing the DataGridView columns.