Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello There,

I have DataGridView and want to add AutoFilter capability to it.
I have downloaded
"DataGridViewAutoFilter.dll" assembly
from http://www.microsoft.com/en-us/download/details.aspx?id=23459[^][^]

Problem : I want to change Column Type To :
DataGridViewAutoFilterTextBoxColumn

Instead of
DataGridViewTextBoxColumn

How to do this???
Please Help!!!
Thanks In Advance!!!
Posted

The DataGridViewAutoFilterTextBoxColumn can be used in the DataGridView as shown below:

  1. Copy the DataGridViewAutoFilter.dll file to the Bin folder of the project concerned
  2. Open Visual Studio, right click on the Project concerned in the Solution Explorer and select the Add Reference menu option from the opened Context menu
  3. In the Add Reference Dialog select the Browse tab page and select the DataGridViewAutoFilter.dll file by navigating to the folder in which it was copied
  4. Now open the Form in design view, on which the DataGridView is placed
  5. Right click on the DataGridView and select Edit columns menu option from the opened context menu
  6. In the opened Dialog select the required column on the left hand side
  7. Then on the right hand side select the DataGridViewAutoFilterTextBoxColumn from the drop down list for the column type


I hope this may serve the purpose.
 
Share this answer
 
Comments
Pravinkarne.31 1-May-12 0:23am    
Hi VJ Reddy,
Thanks for your reply but i have done all this.
My Problem is - I have UnBound DataGridView and I am refreshing this by query.
When I refresh, it automatically shows data in "DataGridViewTextBoxColumn"
I want Refresh UnBound DataGridView with "DataGridViewAutoFilterTextBoxColumn" Column types.

Please help!!!
VJ Reddy 1-May-12 0:36am    
But your question does not say so. It is only asked in the question for how to change the column type to DataGridViewAutoFilterTextBoxColumn
instead of DataGridViewTextBoxColumn, for which the solution given above works. It is better to frame the question properly so that you can get answer as required, and the person who wants to give answer can spend his time in the correct direction instead of wasting time in what you have already done.
I have solved myself!!! Thank You!!!
C#
foreach (DataGridViewColumn col in dataGridView1.Columns)
              {
                col.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(col.HeaderCell);
              }
            dataGridView1.AutoResizeColumns();
 
Share this answer
 
v2
Comments
VJ Reddy 2-May-12 11:36am    
Good solution. 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900