vb.net - Scroll to Datagridview selected Row -
i've done quite bit of searching answer none have been able me. i've attempted use or see if .focus()was applicable since other websites suggested it, not. datagridview, historydata.
to jump selected row. of course not scroll when enough items fill grid. there parameter i'm missing on grid?
here's code:
private sub historysearch_textchanged(sender object, e eventargs) handles historysearch.textchanged try if historysearch.text.tostring <> "" each historyrow datagridviewrow in historydata.rows historydata.clearselection() each historycell datagridviewcell in historyrow.cells if historycell.value.tostring.startswith(historysearch.text.tostring) historyrow.selected = true dim integer = historydata.currentrow.index() else historyrow.selected = false end if if historycell.value.tostring.contains(historysearch.text.tostring) historyrow.selected = true dim integer = historydata.currentrow.index() return else historyrow.selected = false end if next next end if catch ex exception msgbox(ex.message) end try end sub
if understand question correctly, can scroll specific row in datagridview using either of these options:
currentcell
if set currentcell of datagridview selects specified cell , scrolls make cell visible.
for example select last row , scroll it:
'use suitable index, 10 example datagridview1.currentcell = datagridview1.rows(10).cells(0) firstdisplayedscrollingrowindex
you can set firstdisplayedscrollingrowindex scroll specific row, doesn't select row:
for example scroll 10th row:
'use suitable index, 10 example datagridview1.firstdisplayedscrollingrowindex = 10
Comments
Post a Comment