Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create a list that searches and retrieves all the data in list which is matching the searching criteria (the text to search can appears anywhere in the list's string start,middle,end)

Sample Image Of What I Want To Achieve

Now, the situation is i can handle the searching part myself but i dont know how to create control which highlights the matched text in the list in c# win. form
Posted

1 solution

Add one event handler for DrawItem

C#
this.ComboBox1 = new ComboBox();
this.ComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.ComboBox1.DrawItem += new DrawItemEventHandler(ComboBox1_DrawItem);

private void ComboBox1_DrawItem(object sender,
                                System.Windows.Forms.DrawItemEventArgs e)
{
    // use e.Graphics property to draw your own text
    //
    // e.Graphics.DrawString(...));

}


There is a MSDN example here: ComboBox.DrawItem
 
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