Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView display starting point 1

Status
Not open for further replies.

CabinFever

Programmer
Sep 28, 2009
16
0
0
US
VB2008Express
I have a DataGridView bound to a database which sorts by print date (ex. 09/25/2009).
Me.mydata.Fill(Me.mydataDataSet4.myinfo)
Me.mydataBindingSource.Sort = "print date"
The data base consists of past, current and future jobs. Currently I scroll down through the list of past jobs to the find the current days jobs.
Is there a way to sort or 'autoscroll' the rows using the printdate field (compaired to the current days date) to display the rows starting with the first job of the day instead of the very first entry in the database?
 
If you can determine the index of the row with the first date you want to display, you can make that the first row displayed like so:

DataGridView1.FirstDisplayedScrollingRowIndex = RowToDisplay

where RowToDisplay is an integer value, and -1 < RowToDisplay < DataGridView1.Rows.Count


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
This is how I used it. Thanks again!

'=======================
'---Fill DataGridView---
'-----------------------

Me.~my~TableAdapter.Fill(Me.~my~DataSet.~my data~)

'---Sort by "Print Date"---

Me.~my~BindingSource.Sort = "print date"

'---FIND first "Print Date" that equals Today---

Dim FirstJobOfDay As Integer
Dim Today As String
Today = DateString

FirstJobOfDay = ~my~BindingSource.Find("print date", Today)

'---Display first "Print Date" at top of DataGridViewDisplay---

~my~DataGridView.FirstDisplayedScrollingRowIndex = FirstJobOfDay

'----------------------------------
'---Ends Sort of GridViewDisplay---
'==================================

 
How can I alter the following?

(Let me know if I need to start a new thread for this)

'=======================
'---Fill DataGridView---
'-----------------------

Me.~my~TableAdapter.Fill(Me.~my~DataSet.~my data~)

'---Sort by "Print Date"---

Me.~my~BindingSource.Sort = "print date"

'---FIND first "Print Date" that equals Today---

Dim FirstJobOfDay As Integer
Dim Today As String
Today = DateString

FirstJobOfDay = ~my~BindingSource.Find("print date", Today)

'---Display first "Print Date" at top of DataGridViewDisplay---

~my~DataGridView.FirstDisplayedScrollingRowIndex = FirstJobOfDay

'----------------------------------
'---Ends Sort of GridViewDisplay---
'==================================

When I change Me.~my~BindingSource.Sort = "print date" to Me.~my~BindingSource.Sort = "print date, press"

My datagridview groups the press rows together and lists print date in ascending order according to todays date just fine, except it won't show the first day at the top of grid. It will start somewhere within todays date entries.

But if I change my PC calender clock to any other day (past or future) it works perfect, first job at the top. Just not on current days date.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top