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

ListView Find Items Text

, 8 Jun 2007
Rate this:
Please Sign up or sign in to vote.
ListView Find Items string or integer etc: *text, or *text*, or text*
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

Share

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....

Comments and Discussions

 
GeneralCode Fragment, not an article Pinmemberednrgc8-Jun-07 7:35 
AnswerRe: Code Fragment, not an article PinmemberSuha8-Jun-07 12:31 
QuestionWAT IS THIS??? Pinmemberpablleaf8-Jun-07 7:34 
AnswerRe: WAT IS THIS??? PinmemberSuha8-Jun-07 12:33 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 8 Jun 2007
Article Copyright 2007 by Suha
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid