Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jan 2, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determine Absolute Row Index

Often, properties and methods associated with grid controls don't provide an absolute (relative to the actual first row and not the first displayed row) row index of current or selected rows. Sample code below provides the index of the current row, assuming the absolute first row has an index of 0:
    'Get the absolute row index of the current row

    Dim iCounter as Integer

    iCounter = 0
    While Not IsNull(grd.GetBookmark(iCounter - 1))     'grd is a name for the Grid
        iCounter = iCounter - 1
    iCounter = Abs(iCounter)

Note: iCounter is the current absolute row index. GetBookmark is a public method provided by the grid. Null is returned when the offset reaches BOF.
Nazmul Siddiqui
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date