Click here to Skip to main content
15,883,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !
I required Widows Based Solution.In web I solved by using Webservices(Ajax/AutocompleteExtender).

I have bind data in a comboboxcolunn in DataGridView. I want to filter the list according to words typed.
It may be automatically by setting the property. If not possible it may be by passing SQL Query.

It should be similar result as I use like operater ('%"+ txt1.Text +"%')on button Event. But in combobox I want automatic filter.

I used independent ComboBox it works filter from begining of the list automatically without SQL Query.
But I want list after typing words compared from any place either from begening or middle in both ComboBox and ComboBoxColumn in DataGridView without using SQL Query if possible or any ways.
Posted
Updated 6-May-13 22:34pm
v2
Comments
LebneizTech 7-May-13 6:47am    
Hi !
I have completed 90%.Only 1 things left is that text that I type it compare from left only.But I required from any location of the word in the list.

Solutions is for DataGridViewComboBoxColumn:
private void gvAdd_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (gvAdd.CurrentCell.ColumnIndex == gvAdd.Columns[0].Index)
{
cmbI = e.Control as ComboBox;
cmbI.SelectedIndexChanged -= new EventHandler(ddlItems_SelectedIndexChanged);
cmbI.SelectedIndexChanged += new EventHandler(ddlItems_SelectedIndexChanged);

((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown;
((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.ListItems;
((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;

}
}
and for Combobox :
AutoCompleteStringCollection col = new AutoCompleteStringCollection();
int i = 0;
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
col.Add(ds.Tables[0].Rows[i][FieldsName].ToString());
// col.Add(ds.Tables[0].Rows[i]["phone_no"].ToString());
}
cmb1.AutoCompleteSource = AutoCompleteSource.CustomSource;
cmb1.AutoCompleteCustomSource = col;
cmb1.AutoCompleteMode = AutoCompleteMode.Suggest;
con.Close();

1 solution

Have a look at: An ASP.NET DataGrid with AutoFilter[^]

If you are using Windows Forms then DataGridView Filter Popup[^] provides something similar.


Best regards
Espen Harlinn
 
Share this answer
 
v2
Comments
LebneizTech 7-May-13 4:35am    
Sir,
It is web based solution, but i required Windows Based.
Espen Harlinn 7-May-13 6:42am    
You tagged the question with the ASP tag, which is a web based technology ...
Sergey Alexandrovich Kryukov 11-Jun-13 19:49pm    
5ed. For the OP, too late to fix the question... :-)
—SA
Espen Harlinn 12-Jun-13 15:47pm    
Thank you, Sergey :-D
Sergey Alexandrovich Kryukov 11-Jun-13 19:50pm    
Oh, I did not pay attention that "DataGridView" is only "System.Windows.Forms.DataGridView" (unlike other types with different names), so you could have guessed what it is, but, formally, inquirers should not mislead... :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900