Jump to content

Autocomplete Textbox in C#

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
alipalang

alipalang

    Newbie

  • Members
  • Pip
  • 1 posts
Hi Everybody,
I developed a windows application form with C# for a Flower Shopping Store. I want one of the Textboxes of form be in Autocomplete mode and fetching its data from a dataset that has been added to the applicatin already. Please help me. Here is my 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;
using System.Data.SqlClient;

namespace FlowerShopping
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void customersBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.customersBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.flowerShoppingDataSet);

}

private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'flowerShoppingDataSet.Customers' table. You can move, or remove it, as needed.
this.customersTableAdapter.Fill(this.flowerShoppingDataSet.Customers);
//creat auto complete Collection
AutoCompleteStringCollection collection = new AutoCompleteStringCollection();
//get the data from dataset.
FlowersNameDataSet ad = new FlowersNameDataSet();
DataTable dt = new DataTable();
ad.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//add the student name into auto complete collection
collection.Add(dt.Rows[i].ItemArray[0].ToString());
}
}
//after adding the student names into auto complete collection bind the collection to textbox
flower_NameTextBox.AutoCompleteMode = AutoCompleteMode.Suggest;
flower_NameTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
flower_NameTextBox.AutoCompleteCustomSource = collection;

}
}
}




Error 1 'FlowerShopping.FlowersNameDataSet' does not contain a definition for 'Fill' and no extension method 'Fill' accepting a first argument of type 'FlowerShopping.FlowersNameDataSet' could be found (are you missing a using directive or an assembly reference?)

Back to top

Edited by WingedPanther, 13 October 2009 - 08:01 AM.
add code tags (the # button)


#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
You need to modify the FlowerNameDataSet to a proper type that the Fill method accepts
Posted via CodeCall Mobile