|
-
Oct 27th, 2009, 02:30 PM
#1
Thread Starter
Addicted Member
filter DGV
Hi All.
In ToolStrip of DGV form I have DateFromDateTimePicker and DateToDateTimePicker. I would lke to filter DVG by values of these DateTimePicker.
Thanks.
Last edited by eugz; Oct 27th, 2009 at 03:44 PM.
-
Oct 27th, 2009, 04:34 PM
#2
Hyperactive Member
Re: filter DGV
How have you bound the DGV.
I have done this sort of thing and the way I did was to add an SQL statement to the TABLEADAPTER where I added the filter points which you do within the Dataset Designer. Having bound the DATABINDINGSOURCE to the DGV, I filtered it thus:
Code:
Private Sub FilterData()
me.tableadpter.fillby(dataset.recordset, datefrom,dateto)
EndSub
This would fill the datagrid with the required info.
Computerman.
It was much easier in VB6, but I am now liking Vb.Net alot more. 
-
Oct 27th, 2009, 07:44 PM
#3
Hyperactive Member
Re: filter DGV
You can apply a dataview to your dataset and use RowFilter to filter the data. Something like this:
Code:
' This uses the DateTimePicker to select start and ending dates
Dim mStart As DateTime = dtpStart.Value
Dim mEnd As DateTime = dtpEnd.Value
'
dv.Sort = "TransDate"
dv.RowFilter = String.Format("TransDate >= #{0:M/dd/yyyy}# AND TransDate <= #{1:M/dd/yyyy}#", mStart, mEnd)
-
Oct 27th, 2009, 08:16 PM
#4
Re: filter DGV
You imply that you've already got a BindingSource bound to your grid. In that case you should have just set the Filter property of that BindingSource. It's exactly this sort of thing that the BindingSource exists for.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|