Friday, 4 January 2013

AutoComplete Textbox in Windows Application C#.Net




C#
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 WindowsFormsApplication23
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }
        DataClasses1DataContext l = new DataClasses1DataContext();
        int i;
        private void Form4_Load(object sender, EventArgs e)
        {
            AutoCompleteStringCollection a = new AutoCompleteStringCollection();
            for (i = 0; i < l.Tasks.ToList().Count; i++)
                a.Add(l.Tasks.ToList()[i].Subject);
            textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
            textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
            textBox1.AutoCompleteCustomSource = a;
        }
    }
}
 

No comments:

Post a Comment