 |
| Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 23rd, 2009, 02:24 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
Reset DataGrid after filtering column
I have a form with a datagrid on it and textbox and one button with the button I filter one column.
This now works.
I would like to add a another button to reset the datagrid so I can refilter another column?
|
|

November 24th, 2009, 07:34 AM
|
|
Registered User
|
|
Join Date: Nov 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry i cant help coz am new in vb
|
|

November 24th, 2009, 07:48 AM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
Reset DataGrid after filtering
Thank you for having a look I am a begginer to?
|
|

November 24th, 2009, 09:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Hello..
If you are loading the grid at startup, why not do the same but using the button???
Or apply an empty filter...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
The Following User Says Thank You to gbianchi For This Useful Post:
|
|
|

November 24th, 2009, 05:51 PM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
DataGrid filtering columns
How my datagrid filtering is working and i can reset my datagrid can someone help me with my next problem.
In my datagrid I have a column with dates i would like my filtering to select the column dates as a second filter with the first filter column names with dates in ascending order please?
|
|

November 25th, 2009, 07:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
You need to apply the filter directly to the grid, or the selected data?? I don't know how much data you have, but probably this will be faster on the database.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
The Following User Says Thank You to gbianchi For This Useful Post:
|
|
|

November 25th, 2009, 08:09 AM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
Filter columns
Gonzalo can help with code?
My code is not working for the second filter
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'sets filter string WHERE clause in the form "Where COLUMNNAME like '@FilterText'"
Me.SWR2010BindingSource.Filter = String.Format("{0} like '%{1}%'", Me.EMP1DataSet.SWR2010.Site_EmployeeColumn.ColumnName, Me.TextBox1.Text)
Catch ex As Exception
MsgBox("ERROR")
End Try
Try
'sets seconed filter string WHERE clause in the form "Where COLUMNNAME like '@FilterTextDate'" = DD/MM/YY
Me.SWR2010BindingSource.Filter = Int16.TryParse("{0} like '%{1}%'", Me.EMP1DataSet.SWR2010.Site_DateColumn.ColumnName.ToString)
Catch ex As Exception
MsgBox("ERROR") 'A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
End Try 'When i select filter
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Me.SWR2010BindingSource.RemoveFilter()
Me.TextBox1.Text = ""
Catch ex As Exception
MsgBox("ERROR")
End Try
End Sub
|
|

November 25th, 2009, 08:25 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Your second filter is missing the data for the second parameter. Also you are using columnname.tostring on the second filter (and the first one is different)..
check that out.
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
The Following User Says Thank You to gbianchi For This Useful Post:
|
|
|

November 25th, 2009, 09:07 AM
|
|
Authorized User
|
|
Join Date: Jul 2009
Posts: 30
Thanks: 10
Thanked 0 Times in 0 Posts
|
|
Filter columns
I have recoded the line
But it will not except Me.Textbox1.text i do not need this for i only wont this filter to put the date column in ascending order
Me.SWR2010BindingSource.Filter = Date.ParseExact("{0} like '%{1}%'", Me.EMP1DataSet.SWR2010.Site_DateColumn.ColumnName, Asc)
Error 1 Overload resolution failed because no accessible 'Asc' accepts this number of arguments.
|
|

November 25th, 2009, 08:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
Ok. Take a deep breath.
Think what you are asking me and what you are trying to do.
You don't want a filter.. you want a sort. You don't use like to apply a sort, you sort the info...
With that in mind, you want to sort it how??? (I know, by date, but how, when you take it?? the collection you use to fill the grid??)
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
The Following User Says Thank You to gbianchi For This Useful Post:
|
|
|
 |