c# listbox search In .net



This is A C# Practice code:
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Linq;
        using System.Text;
        using System.Windows.Forms;

        namespace database
        {
            public partial class ListboxSearch : Form
            {
                public ListboxSearch()
                {
                    InitializeComponent();
                }

                private void button1_Click(object sender, EventArgs e)
                {
                    listBox1.SelectedItems.Clear();
                    for (int num = listBox1.Items.Count -1; num >= 0; num--)
                    {
                        if (listBox1.Items[num].ToString().ToLower().Contains(textBox3.Text.ToLower()))
                        {
                            listBox1.SetSelected(num,true);
                        }
                    }
                    label3.Text = listBox1.SelectedItems.Count.ToString(); ;
                }

                private void textBox3_TextChanged(object sender, EventArgs e)
                {

                }

                private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
                {

                }
            }
        }

Video For Result:



Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Facebook Comment