471,594 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

datagridview control easy filtering ?

I'm trying to set my datagridview so that the first row will be left blank
and to use it as a filtering filed for the datagridview. Until now I was
using 2 datagridview the upper one with a header that sort and one row for
filtering and the lower one with no header for the data. Only it is very
complicated to work this way cause for example when the user click on sort
on the upper datagridview I need to sort the lower grid and so on when the
user change the size of column on the upper datagridview I need to change
the lower one accordingly. Any advice on how to do this ??
Nov 17 '05 #1
10 13196
Hi Milk-jam,

Welcome to MSDN newsgroup.
Regarding on the displaying additional filter row in DataGridView/DataGrid
question, we'll have a look and do some research and will update you as
soon as possible. Thanks for your understanding.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "milk-jam" <mi******@newsgroups.nospam>
| Subject: datagridview control easy filtering ?
| Date: Sat, 27 Aug 2005 12:48:28 +0200
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#t*************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: hfa62-0-138-26.bb.netvision.net.il 62.0.138.26
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.languages.csharp:118718
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I'm trying to set my datagridview so that the first row will be left
blank
| and to use it as a filtering filed for the datagridview. Until now I was
| using 2 datagridview the upper one with a header that sort and one row
for
| filtering and the lower one with no header for the data. Only it is very
| complicated to work this way cause for example when the user click on
sort
| on the upper datagridview I need to sort the lower grid and so on when
the
| user change the size of column on the upper datagridview I need to change
| the lower one accordingly. Any advice on how to do this ??
|
|
|

Nov 17 '05 #2
Hi milk-jam,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to sort the lower datagridview
control according the the upper one's sort. If there is any
misunderstanding, please feel free to let me know.

In this case, you can try to handle the DataGridView.Sorted event. In this
event, you can get the sorted column using DataGridView.SortedColumn, and
then set the lower DataGridView's sorted column accordingly.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #3
Nop, thats not what im trying to achive at all, thats what im doing at the
moment.
What im trying to achive is to use 1 datagridview and to skip the first row
when i populate the datagridview and i wanna use the first row for
filtering. because i couldnot find the way to do it i used 2 datagridview
but my solution complicate evrything and i wanna find a way to do it with 1
datagridview.

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:ir*************@TK2MSFTNGXA01.phx.gbl...
Hi milk-jam,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to sort the lower
datagridview
control according the the upper one's sort. If there is any
misunderstanding, please feel free to let me know.

In this case, you can try to handle the DataGridView.Sorted event. In this
event, you can get the sorted column using DataGridView.SortedColumn, and
then set the lower DataGridView's sorted column accordingly.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #4
Hi milk-jam,

Do you mean that you need to change the header row of DataGridView to a
filter that can filter the data in the column just like turning Filter on
in Excel?

If so, you have to subclass the DataGridView class and add ComboBoxes to
the header row. When a user selects from this ComboBox, set the rowfilter
property of the DataView. There is no specific code sample for this, but
you can check the following sample for reference.

http://www.codeproject.com/cs/miscct...ridColumns.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #5
Hi milk-jam,

Do you mean that you need to change the header row of DataGridView to a
filter that can filter the data in the column just like turning Filter on
in Excel?

If so, you have to subclass the DataGridView class and add ComboBoxes to
the header row. When a user selects from this ComboBox, set the rowfilter
property of the DataView. There is no specific code sample for this, but
you can check the following sample for reference.

http://www.codeproject.com/cs/miscct...ridColumns.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #6
Yes thatís what I'm trying to do

But I donít understand how to do it ?

How to I add a ComboBoxes to the header row

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:H6**************@TK2MSFTNGXA01.phx.gbl...
Hi milk-jam,

Do you mean that you need to change the header row of DataGridView to a
filter that can filter the data in the column just like turning Filter on
in Excel?

If so, you have to subclass the DataGridView class and add ComboBoxes to
the header row. When a user selects from this ComboBox, set the rowfilter
property of the DataView. There is no specific code sample for this, but
you can check the following sample for reference.

http://www.codeproject.com/cs/miscct...ridColumns.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #7
Yes thatís what I'm trying to do

But I donít understand how to do it ?

How to I add a ComboBoxes to the header row

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:H6**************@TK2MSFTNGXA01.phx.gbl...
Hi milk-jam,

Do you mean that you need to change the header row of DataGridView to a
filter that can filter the data in the column just like turning Filter on
in Excel?

If so, you have to subclass the DataGridView class and add ComboBoxes to
the header row. When a user selects from this ComboBox, set the rowfilter
property of the DataView. There is no specific code sample for this, but
you can check the following sample for reference.

http://www.codeproject.com/cs/miscct...ridColumns.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #8
Hi milk-jam,

Sorry, but with my further research, I found that the header row of the
DataGridView is highly encapsuled. So I don't suggest you to do this. You
can try to add ComboBoxes above the DataGridView to achieve this.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #9
I think my 2 datagridview solution is easier to work with than using
ComboBoxes above the header.
Lets say the user drag column1 and drop it after column 4, will be easier to
triger the same even in the second datagridview than to try and replace the
ComboBoxes location. But im sure there is away to add a Control to the
header. It interesting to know what was used in outlook 2003 when u choose
contacts and choose by category view or by phone list. there is a row under
the header that let u add a contact thats exactly the solution i need. i
dont belive the outlook team used 2 datagrids.
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Oy**************@TK2MSFTNGXA01.phx.gbl...
Hi milk-jam,

Sorry, but with my further research, I found that the header row of the
DataGridView is highly encapsuled. So I don't suggest you to do this. You
can try to add ComboBoxes above the DataGridView to achieve this.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #10
Hi milk-jam,

Actually the grid control used in Outlook is different from the one in
VS.NET. In Microsoft, each product team implents their own controls. So
because the Outlook team has the souce code for their grid control, they
can customize it to satisfy thieir needs. However, the DataGridView in
VS.NET is highly encapsuled to meet general requirements, it's hard for us
to do such a job on it. I think your solution is fine for workaround. I'm
sorry for the inconvenience.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Job Lot | last post: by
7 posts views Thread by Mitchell S. Honnert | last post: by
2 posts views Thread by ewingate | last post: by
2 posts views Thread by =?Utf-8?B?VmFuZXNzYQ==?= | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.