Click here to Skip to main content
15,889,281 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can i do filter datagridview in C#

What I have tried:

I add value
C#
dataGridView1.Rows[setr].Cells[1].Value = values[0];

I dont use datagrid source
Posted
Updated 21-Oct-16 4:49am
Comments
OriginalGriff 21-Oct-16 8:33am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What does filtering have to do with setting the value of a particular sell?
Use the "Improve question" widget to edit your question and provide better information.
[no name] 21-Oct-16 8:42am    
Did you read the documentation? Many times they have example code.

1 solution

One of the way is to, instead of adding rows to the datagridview, add datarows to a datatable and then once datatable is ready make it the datasource of your datagridview.

Something like-
C#
DataTable table = new DataTable();
table.Columns.Add("Name", typeof(String));
table.Columns.Add("...", typeof(String));


foreach (var element in list)
   table.Rows.Add(element.Name, element.Something);


dataGridView1.DataSource = table1;
table.DefaultView.RowFilter = "Name Like '...'";


For detailed answer, check the following thread in stackoverflow-
c# - Filtering an DataGridView that doesn't have databinding - Stack Overflow[^]

Hope, it helps :)
 
Share this answer
 

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