Hi Phillip,
I spend few hours trying to make TreeListView to show highlighted items but unsuccessfully.
Before I start putting code, let me just explain that I use TreeListView control and I really have tree structure.
First I tried the code available in 'Learn to Cook':
TextMatchFilter filter = new TextMatchFilter(this.treeListView1, toolStripTextBox1.Text);
this.treeListView1.DefaultRenderer = new HighlightTextRenderer(filter);
But that didn't work. I added:
this.treeListView1.Refresh();
But that didn't help either. Then, I added Renderer to one of the columns (not first column):
TextMatchFilter filter = new TextMatchFilter(this.treeListView1, toolStripTextBox1.Text);
this.treeListView1.DefaultRenderer = new HighlightTextRenderer(filter);
this.olvColumnObjectID.Renderer = new HighlightTextRenderer(filter);
And then it started to work but for all columns except first one. After that I modified third row by putting first row instead:
TextMatchFilter filter = new TextMatchFilter(this.treeListView1, toolStripTextBox1.Text);
this.treeListView1.DefaultRenderer = new HighlightTextRenderer(filter);
this.olvColumnObjectName.Renderer = new HighlightTextRenderer(filter);
But then strange thing happened - highlighter started working normally but tree lines, pluses and minuses 'disappeared'.
Please check attachment.
If I am doing something wrong, please let me know.
Thanks,
Miljan
Sorry, this isn't very clear.
On a
TreeListView, theDefaultRendereris used for all columns except the first. The first column is drawn by theTreeColumnRenderer, which has to be an instance ofTreeRenderer.TreeRendereralready supports text highlighting. You just need to change theFilterproperty.So your code just needs to add a single line to update the
Filterproperty: