When i am selecting any product from Product combo box associated Model_no fill into Model combo box but one product having thousand of model's.
I want to filter data into Model combo box.
Suppose If model no is : LED UA65ES8000
When i type 65 into Model Combo box all model no should come those having 65
Satyapriya NayakPosted Feb 10, 2013, 1:18 PM
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.OleDb;
namespace Filter_Combobox
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oda;
DataSet ds;
string str;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bind();
}
private void bind()
{
comboBox1.Text = "--Select--";
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from prod ";
com = new OleDbCommand(str, con);
oda = new OleDbDataAdapter(com);
ds = new DataSet();
oda.Fill(ds, "prod");
comboBox1.Items.Clear();
comboBox1.DataSource = ds.Tables["prod"];
comboBox1.ValueMember = "Modelid";
comboBox1.DisplayMember = "ModelNo";
con.Close();
}
private void comboBox1_MouseDown(object sender, MouseEventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from prod where ModelNo like '%" + comboBox1.Text + "%'";
com = new OleDbCommand(str, con);
oda = new OleDbDataAdapter(com);
ds = new DataSet();
oda.Fill(ds, "prod");
comboBox1.DataSource = ds.Tables["prod"];
comboBox1.ValueMember = "Modelid";
comboBox1.DisplayMember = "ModelNo";
con.Close();
comboBox1.Text = "";
}
}
}
Thanks
If this post helps you mark it as answer
Mayur DighePosted Feb 10, 2013, 9:27 AM
you can do it....buddy........
just include the previous string into your search operation....means..
if you want search all records from LED UA65 series , just make sure that you are comparing LED UA letters along with your entered number...
so first...make a code for verifying in which series you want search....then use search for entered number.
happy Programming...........