简体   繁体   English

有人能告诉我这段代码有什么问题吗?

[英]Can someone tell me what's wrong with this code?

I'm trying to implement a search as you type (like in iTunes). 我正在尝试在您键入时实现搜索(如在iTunes中)。 I am using an ObjectListView . 我正在使用ObjectListView Further, I have a textbox that is used to do the search as shown below: 此外,我有一个用于搜索的文本框,如下所示:

private void textBoxSearch_TextChanged(object sender, EventArgs e)
        {

            string txt = textBoxSearch.Text;
            TextMatchFilter filter = null;
            if (!String.IsNullOrEmpty(txt))
            {
                filter = TextMatchFilter.Contains(myObjectListView, txt);
            }
            // Setup a default renderer to draw the filter matches
            if (filter == null)
                myObjectListView.DefaultRenderer = null;
            else
            {
                myObjectListView.DefaultRenderer = new HighlightTextRenderer(filter);

                // Uncomment this line to see how the GDI+ rendering looks
                myObjectListView.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false };
            }

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = myObjectListView.GetColumn(0).Renderer as HighlightTextRenderer;
            if (highlightingRenderer != null)
                highlightingRenderer.Filter = filter;

            myObjectListView.ModelFilter = filter;
        }

Can someone figure out why this doesn't work? 有人能弄清楚为什么这不起作用? The above code is meant to filter search results as the user types in the textbox (Like iTunes does, if you have ever used itunes). 上面的代码用于在用户在文本框中键入时过滤搜索结果(如果你曾经使用iTunes,就像iTunes一样)。 Apparently, up to this point, nothing happens. 显然,到目前为止,没有任何反应。 It seems like this code does not even execute. 看起来这个代码甚至都没有执行。

对此ObjectListView有一个名为UseFiltering的属性,默认情况下为false ,必须设置为true才能启用过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有人可以向我解释我的代码有什么问题吗? - Can someone explain to me what's wrong with my code please? 任何人都可以告诉我这部分代码有什么问题 - Can anyone tell me what's wrong in this part of code 有人可以告诉我此反向传播实现的问题是什么 - Can someone tell me what is wrong with this back propagation implementation 谁能告诉我这个ZeroMQ代码有什么问题吗? - Can anyone tell me what is wrong with this ZeroMQ code? 有人能告诉我我的log4net配置/实现有什么问题吗? - Can someone tell me what is wrong with my log4net config/ implementation? 有人可以告诉我List,Collection和Enumerable之间的区别是什么? - Someone can tell me what's the difference between List, Collection and Enumerable? 有人能告诉我这意味着WriteLine(“{0,-12}”) - Can someone tell me what this means WriteLine(“{0,-12}”) 有人可以告诉我我的班级标题出了什么问题吗? - Can someone tell me what the problem is with my class header? 有人能告诉我这段代码使用的是哪个版本的 Angular 吗? - Can someone tell me which version of Angular is this code using? 谁能告诉我这个更新声明有什么问题? 访问数据库 - Can anyone tell me what's wrong with this Update Statement? Access Mdb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM