Hi All.
In ToolStrip of DGV form I have DateFromDateTimePicker and DateToDateTimePicker. I would lke to filter DVG by values of these DateTimePicker.
Thanks.
Printable View
Hi All.
In ToolStrip of DGV form I have DateFromDateTimePicker and DateToDateTimePicker. I would lke to filter DVG by values of these DateTimePicker.
Thanks.
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:
This would fill the datagrid with the required info.Code:Private Sub FilterData()
me.tableadpter.fillby(dataset.recordset, datefrom,dateto)
EndSub
Computerman. :)
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)
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.