using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;

namespace ListBox_CS
{
    public partial class Form1 : Form
    {
        const int LB_FINDSTRING = 0x018F;
        const int LB_FINDSTRINGEXACT = 0x01A2;

        [DllImport("coredll.dll")]
        static extern int SendMessage(IntPtr hwnd, int msg, 
            int wParam, string lParam); 

        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else       
                MinimizeBox = true;
            #endif
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //поиск строки по вводимым символам
            listBox1.SelectedIndex = SendMessage(listBox1.Handle, LB_FINDSTRING, -1, textBox1.Text);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add("bank");
            listBox1.Items.Add("banana");
            listBox1.Items.Add("ball");
            listBox1.Items.Add("bounty"); 
            listBox1.Items.Add("bar");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.SelectedIndex = SendMessage(listBox1.Handle, LB_FINDSTRINGEXACT, -1, "ball");
        }
    }
}