|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Stepping through datagridview rows in codeHi All
I have a datagridview bound to a datatable Due to the use of touch screens I need to be able to scroll the grid in code in response to a button click i.e each button touch (click) will move the selection up 1 row How do I do that Regards Steve steve wrote:
Show quoteHide quote > Hi All You need to change the current cell. I don't remember the exact code > > I have a datagridview bound to a datatable > > Due to the use of touch screens I need to be able to scroll the grid in code > in response to a button click > i.e each button touch (click) will move the selection up 1 row > > How do I do that > > > Regards > Steve > > but it'll be something like: DataGridView.CurrentCell = DataGridView.Rows(RowIndex -1).Cells(0) of course you need to check that it's not less than 0 Chris Hi Steve,
Thank you for posting! To simply scroll the DataGridView without changing selected rows, you can use the property FirstDisplayedScrollRowIndex, To change the selection while scrolling, you can first get the current selected row's index by "DataGridView1.SelectedRows(0).Index", then you can determine the index of next or previous row. Then use following code to change selection: DataGridView1.Rows(newindex).Selected = True Though you may need to set the DataGridView's selection mode to single selection first: DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect DataGridView1.MultiSelect = False If there's anything unclear, please feel free to post here. Regards, Walter Wang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Hi Walter
Just what I needed Thanks heaps Regards Steve Show quoteHide quote "Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message news:h3kqh1UfGHA.5992@TK2MSFTNGXA01.phx.gbl... > Hi Steve, > > Thank you for posting! > > To simply scroll the DataGridView without changing selected rows, you can > use the property FirstDisplayedScrollRowIndex, > > To change the selection while scrolling, you can first get the current > selected row's index by "DataGridView1.SelectedRows(0).Index", then you > can > determine the index of next or previous row. Then use following code to > change selection: > > DataGridView1.Rows(newindex).Selected = True > > Though you may need to set the DataGridView's selection mode to single > selection first: > > DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect > DataGridView1.MultiSelect = False > > > If there's anything unclear, please feel free to post here. > > Regards, > > Walter Wang > Microsoft Online Community Support > > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no > rights. > Steve.
Try to avoid for every bounded control to access it direct. Use the currencymanager, where you than are playing with the position of that. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclasstopic.asp I hope this helps, Cor Show quoteHide quote "steve" <ga630sf@newsgroups.nospam> schreef in bericht news:exCYRrSfGHA.3572@TK2MSFTNGP04.phx.gbl... > Hi All > > I have a datagridview bound to a datatable > > Due to the use of touch screens I need to be able to scroll the grid in > code in response to a button click > i.e each button touch (click) will move the selection up 1 row > > How do I do that > > > Regards > Steve >
Resetting the value of a System.Web.UI.HtmlControls.HtmlInputFile
Order of events, databinding, and UserControls Ayuda contra unos programadores de Linux y PHP que me quieren dañar un negocio Printing second time fails Transparent Form surface Really puzzled (or maybe just totally confused) about VB.NET and ADO.NET AppStartup "Cancel" leaves splash form loaded Determining whether the current item is the last one from inside ItemDataBound My.Application.Log.WriteEntry Is Cool, But Formated Information SUCKS Setup question |
|||||||||||||||||||||||