We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Programatically Highlight & Move to a Grid Row

Hi I have a DBG bound to a dataset. I have a column in my grid called "barcode" and I have a event which collects the input of a barcode scanner. I would like to somehow highlight and scroll to the row (if the item if scrolled down the page) which matches my scanned barcode. I can loop through the dataset column easily enough but I dont know how to highlight the row based on its databinding position (in case the grid has been sorted). Could you point me in the right direction? Thanks Mark (vb.net)

1 Reply

AD Administrator Syncfusion Team July 2, 2004 07:59 AM

>>I can loop through the dataset column easily enough If you are working with sorts, then looping through the DataSet column will not be very useful. Instead, you should loop through the list in the CurrencyManager as this will reflect the sort, and the position you find in that list will map to the position of that row in the grid. You can use this code to get the DataView associated with the sorted table. Dim cm as Currencymanager = CType(Me.BindingContext(me.Grid.DataSource, me.Grid.DataMember), CurrencyManager) dim dv as DataView = CType(cm.List, DataView) Then you can loop through the DataView to find the position of the barcode. Then to get the grid rowindex and select the row, you can use code like Dim rowIndex as integer = me.grid.Binder.PositionToRowIndex(position) me.grid.ScrollCellInView(rowIndex, 1) me.grid.Selections.Add(GridRangeInfo.Row(rowIndex))

Loader.
Live Chat Icon For mobile
Up arrow icon