简体   繁体   中英

telerik winform Grid, filtering not working

I use Telerik GridView in winform Project. this is my code:

this.radGridView1.EnableHotTracking = true;
this.radGridView1.ShowFilteringRow = true;
this.radGridView1.EnableFiltering = true;
this.radGridView1.EnableCustomFiltering = true;
DataTable table1 = new DataTable("Deducations");
table1.Columns.Add("R1");
table1.Columns.Add("R2");
table1.Columns.Add("R3");
Random rnd = new Random();
for (int i = 0; i < 100; i++)
{
    DataRow row = table1.NewRow();
    row[0] = rnd.Next(26, 360);
    row[1] = rnd.Next(36, 460);
    row[2] = rnd.Next(46, 560);
    table1.Rows.Add(row);
}
radGridView1.DataSource = table1;

Filtering row is showing But, not working.

It'd be helpful if you could elaborate a bit more about your issues rather than just say something didn't work. Anyway I'd say it might be worth looking at this line of code.

this.radGridView1.EnableCustomFiltering = true;

Above line indicates that you've enabled the Custom Filtering feature in the grid control, which means you have to write code to handle the custom filtering event yourself.

this.radGridView1.CustomFiltering += new GridViewCustomFilteringEventHandler(radGridView1_CustomFiltering);

private void radGridView1_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e)
{
    // your code...
}

Have you implemented this event? If you have, could you perhaps show us the code and let us know if any errors has occurred in it?

But if you don't need to use Custom Filtering, then just disable it or remove the line. All you need is the following two lines to enable the basic filtering feature.

this.radGridView1.EnableFiltering = true;
this.radGridView1.MasterTemplate.EnableFiltering = true;

Also take a look at following links. I hope you find them helpful too.

http://docs.telerik.com/devtools/winforms/gridview/filtering/basic-filtering

http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM