|
I have a employee table id,name,address,deptno,deptname.And i have a department table deptno,deptname.
Now using an inner join i join both of these tables where on my datagridview i get name,address,deptno,deptname where it is
a combobox column.Now i did filtering using from" building a dropdown filter list for a data grid view column header cell" now i
am able to excelent apply auto filter concept .but ineed to implement "Multi select filter" and "quick-filter" a data type specific
filtering which is not provided by "drop down list for a data grid view column header cell".So how do i implement it
can u send me a refrence code.Can u plz help me out.
Thanks in advance
|
| swpa Thursday, November 27, 2008 1:27 PM |
Hi swps,
Welcome to MSDN again.
Here is an example I have written for you to implement multicolumn filter. When you make the filterText, you should put all condition in the drop down list together link with “and�
Code Snippet
// Filter string for multicolumn
string filterText = @" Column1 = 3 and Column3 = 'Item4' ";
// Get DataRow collection from the select method
DataRow[] dr = dtTest.Select(filterText);
// Create a new DataTable to hold these filtered rows
DataTable newTable = dtTest.Clone();
for (int i = 0; i < dr.Length; i++)
{
DataRow drNewRow = newTable.NewRow();
drNewRow[0] = dr[i][0];
drNewRow[1] = dr[i][1];
drNewRow[2] = dr[i][2];
newTable.Rows.Add(drNewRow);
}
// Rebind the dataGridView1 with the DataTable after filter
dataGridView1.DataSource = newTable;
Sincerely,
Kira Qian |
| Kira Qian Monday, December 01, 2008 3:56 AM |
Thanks for ur response Mr.KiraQian. i didnt understand wat i should give in my filter text according to my requirement .
can u plz tell me.
|
| swpa Monday, December 01, 2008 5:06 AM |
Thanks for ur response Mr.KiraQian i ve implemented filtering in my program by "building a drop-down fiter list for a data grid
view column header cell" but i does not consistof multiselect filter feature .Moreover it should be user point of view i need to
implement multiselectfilter directly on the column header cell .And need to also implement quick filter becauze i have a
column called Salary where i neeed to specify >,<,>=,<= using quick filter as it is in the excel sheet and also need to
implement the check boxes to select wat all i want to filter for multi select filter.How do i implement it can u plz send me any
refrence code .I u have any dought about my requirement plz let me know.I do have a dead line so plz help me out .
Thanks once again.
|
| swpa Monday, December 01, 2008 6:27 AM |
Hi swps,
I still have any question about your requirement. What does �b style="">user point of view�mean? I still don’t know what filter you are looking for.
Sincerely,
Kira Qian |
| Kira Qian Monday, December 01, 2008 6:56 AM |
I am looking for a "muti select filter" and a "quick filter " on my column header cell.
|
| swpa Monday, December 01, 2008 10:47 AM |
Hi swps,
Sorry for my misunderstanding. Since you want to implement the column header dropdownbutton filter, this solution is what you are looking for http://msdn.microsoft.com/en-us/library/aa480727.aspx .
Sincerely,
Kira Qian |
| Kira Qian Tuesday, December 02, 2008 2:09 AM |
thanks for ur response.ive already did that but it doesnt have the features such as "multiselect filter" and "quick filter" .
So i need to add them how can i do that.
|
| swpa Tuesday, December 02, 2008 4:39 AM |
Hi swps,
As for the “multiselect filter� You need to put all the filter condition together link with “and�to make the filter string, then use this string to call select method of DataTable as the code I have post you.
I still don’t know the meaning of “quick filter� Could you explain it clearly?
Sincerely,
Kira Qian |
| Kira Qian Tuesday, December 02, 2008 5:07 AM |
First of all i didnt understand wat i need to give for the filter string and secondy the quick filter should be implemented for the
columns Salary where i get to specify the range that is the >=,<=,> for example as soon i click on the column header
cell on the column salary i need to get example: >13000,<13000,>=13000 like that and thirdly when i click on the column
header cell i get all the values of the rows of that particular column i need to able to apply multi select filter with the "drop
down column header cell" i am able apply single select filter but now i need to apply multi select filter. Well i cannot able to
appy ur multiselect code according to my requirement.So can u plz help me out.If u have any doughts abt my requirement plz
let me know.Well i think i need to apply checked list box of datagrid view but i do not know how to apply it.
Thanks in Advance
|
| swpa Tuesday, December 02, 2008 6:07 AM |
Hi swps,
What I mean is when you click the column1’s column header filter and set it to 2 for example, the filter string will be “column1 = 2� when you click the column2’s column header filter and set it to “item3� the filter string should be “column1 = 2 and column2 = ‘item3’� Just make the filter string like this. If you want the Salary column > 13000, the filter string can be “SalaryColumn > 13000�
Does this what you want?
Sincerely,
Kira Qian |
| Kira Qian Tuesday, December 02, 2008 6:39 AM |
Thanks for ur response Mr.Kira Qian .But according to my requirement i need to use the checked list box to my dat grid view.
So that i could implement the multiselect filter using check boxes.how do i implement it to my column header cell in a grid
view.i need to implement it as soon as possible i have a deadline.So plz help me out i am helpless
the code which i implemented for buliding the dropdownfilter list for a data grid view column header cell
by using the data grid view auto filter.
Private void datagridview1_bindingcontextchanged(object sender,Eventargs e) { if(datagridview1.datasource==null) return; foreach(datagridviewcolumn col in datagridview1.columns) { col.headercell=new datagridviewautofiltercolumnheadercell(col.headercell); } datagridview1.autoresizecolumns(); } but this only implemnts single select filter but ineed to implement the multiselect filter which i need to implement it using
checked list box so i need to modify the code so that i can have check boxes to implement the multi select filter.
Thanks in advance
|
| swpa Tuesday, December 02, 2008 12:35 PM |
Hi swps,
I quite know the situation you are facing now, I am also eagerly to find the solution for you. Since the current version of DataGridView doesn’t offer much function so your requirement is hard to meet.
I am sorry to say the solution I will give you can’t fully meet your needs. You can take my suggestion to implement similar function. Here I will introduce some alternative solution.
1. Set the first row of DataGridView as the filter condition row. Hold ListBox control in that row. You can take a look at this example DataGridView control with ListBox .
2. Give the user a filter table, let them choose each condition and press filter button. Than the DataGridView will show the data after being filtered. (similar to the ERP interface of SAP)
3. Put some ListBoxes at the top of the DataGridView, one for each column. After you change the checked item, filter the data in DataGridView. (it doesn’t look nice if you take this solution)
Sincerely,
Kira Qian |
| Kira Qian Wednesday, December 03, 2008 3:19 AM |
Thanks for ur response Mr KiraQian. But plz help me out.
Ive used the concept of datagridviewAutocolumnheadercell where i have the listbox
its been declared in this way
private class filterlistbox:ListBox { Public FilterListBox() { Visible=false; IntegralHeight=true; BorderStyle==BorderStyle.FixedSingle; TabStop=false; }
protected override bool IsInputKey(keys KeyData) { return true; } protected override bool ProcessKeyMessage(ref Message m) { return ProcessKeyEventArgs(ref m); } }
which is already been implemented in the datagridviewcolumnheadercell in the same way i want to add CheckedListBox to
this so how do i implement it like this code.If u have any doughts abt my requirement plz let me know.Plz help me out.
Can u send me a code snippet for Datagridviewcontrol for "checked list box".
thanks in advance.
|
| swpa Wednesday, December 03, 2008 2:32 PM |
Plz help me out .I am unable to solve it.
Thanks in Advance
|
| swpa Monday, December 08, 2008 6:32 AM |
Hi swps,
Sorry, I have tried many kind of solution but no result. Maybe you can try the suggestion in my last post. Thank you for your understanding.
Sincerely,
Kira Qian |
| Kira Qian Monday, December 08, 2008 6:36 AM |