Click here to Skip to main content
Click here to Skip to main content

ListView Find Items Text

By , 8 Jun 2007
 
Title:       ListView Find Items Text
Author:      Suha Celik
Email:       suhacelik@pratek.com.tr
Member ID:   465222
Language:    C# 1.1 or 2.0 
Platform:    Windows, .NET 1.1 or .NET 2.0
Technology:  C#
Level:       Beginner
Description: ListView Find Items Text

ListViewFind

Introduction

ListView Find Items string or integer etc: *text, or *text*, or text*

Using the code

A brief desciption of how to use the article or code. The class names, the methods and properties, any tricks or tips.

        private int lastItm = 0;
.
.
.

private void button1_Click(object sender, EventArgs e)
        {
            int col = Convert.ToInt32(numericUpDown1.Value)-1;
            int colCount = col + 1;
            bool find = false;

            if (checkBox1.Checked)
            {
                colCount = listView1.Columns.Count;
                col = 0;
            }
            for (int colAll = col; colAll < colCount; colAll++)
            {
                for (int lst12 = lastItm; lst12 < listView1.Items.Count; lst12++)
                {
                    if (listView1.Items[lst12].SubItems[colAll].Text.IndexOf(textFind.Text) > -1 |
                        listView1.Items[lst12].SubItems[colAll].Text.ToUpper().IndexOf(textFind.Text.ToUpper()) > -1)
                    {
                        listView1.TopItem = listView1.Items[lst12];

                        if (checkBox2.Checked)
                        {
                            if (lastItm > 0) listView1.Items[lastItm - 1].BackColor = Color.Empty;
                            listView1.Items[lst12].BackColor = Color.Aqua;
                        }
                        lastItm = lst12 + 1;
                        find = true;
                        break;
                    }
                    
                }
                if (find)
                    break;
            }
        }

Enjoy...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Suha
Web Developer PROVERI Tech
Turkey Turkey
Dos , What? Smile | :) (1987 - Goldstar PC)
hmm Dos beautiful,
!!! basic , hello , what?
and next Life Cycle with BASIC (1989)
next VB6
next ASP
next soldier Smile | :)
now full mixed Smile | :)
MSVS 2003 - 2005
Borland c++
ASP
Java
vs....

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralCode Fragment, not an articlememberednrgc8-Jun-07 6:35 
AnswerRe: Code Fragment, not an articlememberSuha8-Jun-07 11:31 
QuestionWAT IS THIS???memberpablleaf8-Jun-07 6:34 
AnswerRe: WAT IS THIS???memberSuha8-Jun-07 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 8 Jun 2007
Article Copyright 2007 by Suha
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid