Click here to Skip to main content
15,906,708 members
Home / Discussions / C#
   

C#

 
GeneralRe: Best way to declaring multiple objects Pin
rfresh20-Aug-13 8:14
rfresh20-Aug-13 8:14 
GeneralRe: Best way to declaring multiple objects Pin
OriginalGriff20-Aug-13 8:41
mveOriginalGriff20-Aug-13 8:41 
QuestionC# Iframe WebBrowser Automation Pin
Abhinav Chitre19-Aug-13 9:41
Abhinav Chitre19-Aug-13 9:41 
AnswerRe: C# Iframe WebBrowser Automation Pin
Richard MacCutchan19-Aug-13 20:51
mveRichard MacCutchan19-Aug-13 20:51 
QuestionC Code Inside Visual Studio 2010? Pin
Member 944713619-Aug-13 5:14
Member 944713619-Aug-13 5:14 
AnswerRe: C Code Inside Visual Studio 2010? Pin
DaveyM6919-Aug-13 5:28
professionalDaveyM6919-Aug-13 5:28 
QuestionWinforms, Console, IPC and stuff Pin
Member 965483119-Aug-13 0:10
Member 965483119-Aug-13 0:10 
SuggestionRe: Winforms, Console, IPC and stuff Pin
Richard MacCutchan19-Aug-13 2:07
mveRichard MacCutchan19-Aug-13 2:07 
QuestionHow to make random Reflection for a ball with c # code? Pin
Member 1020541618-Aug-13 20:11
Member 1020541618-Aug-13 20:11 
AnswerRe: How to make random Reflection for a ball with c # code? Pin
Pete O'Hanlon18-Aug-13 20:40
mvePete O'Hanlon18-Aug-13 20:40 
AnswerRe: How to make random Reflection for a ball with c # code? Pin
Mycroft Holmes18-Aug-13 21:21
professionalMycroft Holmes18-Aug-13 21:21 
QuestionListbox suggestion from textbox Pin
dudz artiaga18-Aug-13 5:33
dudz artiaga18-Aug-13 5:33 
AnswerRe: Listbox suggestion from textbox Pin
Abhinav S18-Aug-13 6:18
Abhinav S18-Aug-13 6:18 
GeneralRe: Listbox suggestion from textbox Pin
dudz artiaga18-Aug-13 15:19
dudz artiaga18-Aug-13 15:19 
AnswerRe: Listbox suggestion from textbox Pin
SaqibRasheed18-Aug-13 11:18
SaqibRasheed18-Aug-13 11:18 
GeneralRe: Listbox suggestion from textbox Pin
dudz artiaga18-Aug-13 15:25
dudz artiaga18-Aug-13 15:25 
GeneralRe: Listbox suggestion from textbox Pin
SaqibRasheed19-Aug-13 2:45
SaqibRasheed19-Aug-13 2:45 
GeneralRe: Listbox suggestion from textbox Pin
BillWoodruff19-Aug-13 11:52
professionalBillWoodruff19-Aug-13 11:52 
AnswerRe: Listbox suggestion from textbox Pin
BillWoodruff18-Aug-13 14:12
professionalBillWoodruff18-Aug-13 14:12 
GeneralRe: Listbox suggestion from textbox Pin
dudz artiaga18-Aug-13 15:27
dudz artiaga18-Aug-13 15:27 
GeneralRe: Listbox suggestion from textbox Pin
BillWoodruff19-Aug-13 12:05
professionalBillWoodruff19-Aug-13 12:05 
AnswerRe: Listbox suggestion from textbox Pin
TnTinMn19-Aug-13 17:14
TnTinMn19-Aug-13 17:14 
If I am understanding you goals correctly give this a try.
Create a new usercontrol and place a textbox and listbox on it.
Then add this as the code behind the control
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class UserControl1 : UserControl
    {
        private DataTable autocompletelist;
        public UserControl1()
        {
            InitializeComponent();

            autocompletelist = new DataTable();
            autocompletelist.Columns.Add("item", typeof(string));
            autocompletelist.DefaultView.Sort = "[item] ASC";
            listBox1.DataSource = autocompletelist;
            listBox1.DisplayMember = "item";
            listBox1.ValueMember = "item";
            listBox1.Visible = false;
            fillautocomplete();// load data in table
            textBox1.TextChanged += textBox1_TextChanged; // wire-up text change handler
            listBox1.DoubleClick += listBox1_DoubleClick; // wire-up double-click handler
            this.Leave += new System.EventHandler(this.UserControl1_Leave);
        }
        private void fillautocomplete()
        {
            // fill the datatable by any means that meets your needs, i.e. a database query
            // for this example I will fill it manually
            autocompletelist.Rows.Add(new object[] { "ape" });
            autocompletelist.Rows.Add(new object[] { "apple" });
            autocompletelist.Rows.Add(new object[] { "apppliance" });
            autocompletelist.Rows.Add(new object[] { "application" });
            autocompletelist.Rows.Add(new object[] { "boy" });
            autocompletelist.Rows.Add(new object[] { "bat" });
        }
        private void textBox1_TextChanged(object sender, System.EventArgs e)
        {
            // note the single quote usage in the filter
            // see: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx
            autocompletelist.DefaultView.RowFilter = "[item] LIKE '" + textBox1.Text + "*'";
            listBox1.Visible = autocompletelist.DefaultView.Count > 0;
        }

        private void listBox1_DoubleClick(object sender, System.EventArgs e)
        {
            if (listBox1.SelectedValue != null)
            {
                textBox1.Text = listBox1.SelectedValue.ToString();
            }
            listBox1.Visible = false;
            textBox1.SelectionStart = textBox1.Text.Length;
            textBox1.Focus();
        }
        public override string Text
        {
            get {return textBox1.Text;}
            set {textBox1.Text = value;}
        }
        private void UserControl1_Leave(object sender, EventArgs e)
        {
            listBox1.Visible = false;
        }
    }
}

GeneralRe: Listbox suggestion from textbox Pin
BillWoodruff20-Aug-13 17:48
professionalBillWoodruff20-Aug-13 17:48 
GeneralRe: Listbox suggestion from textbox Pin
TnTinMn21-Aug-13 4:34
TnTinMn21-Aug-13 4:34 
QuestionSotware Template for manage SMEs Pin
Member 990191217-Aug-13 7:48
Member 990191217-Aug-13 7:48 

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

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