Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Dec 20, 2000



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

Determining an Absolute Row Index

Often properties and methods associated with grid controls don't provide an absolute row index of current or selected rows (relative to the actual first row and not the first displayed row). The 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