Gustav Brock
Gustav at cactus.dk
Thu May 21 12:02:57 CDT 2009
Hi Susan That's not the purpose of a DataTableAdapter. But you could achieve this by adjusting the SQL of the query in the adapter (right-click on it, pick Modify SQL). This is, however, what Shamil refers to as "custom in-line SQL" and warns against as it can be difficult to maintain. He has a point and recommends building a SP that produce the desired limited output and then create an adapter for that. I have used the modified SQL method a lot and have no problem with it, so this is a matter of preference, previous experience, how you define this - as belonging to the database or (as a business rule) to the application, and who is going to maintain the system in the future. As alway in .Net - many ways to skin the cat. /gustav >>> ssharkins at gmail.com 21-05-2009 17:34 >>> Okay, after discussing this a bit with Charlotte, she says the problem is the TableAdaptor -- the VB Configuration Wizard uses a TableAdapter to populate the control. I'm researching this morning, but I can't seem to find anything on editing the TableAdaptor to show only the last few records and the edit row, instead of displaying all of the records. Any help? Susan H. > Using VB Express 8, I added the following to a form class with a > datagridview control, expecting it to limit the number of rows displayed > in the grid, so that the edit row is immediately visible. It doesn't > return an error, but it doesn't seem to do anything at all either -- view > is the same with or without this sub. > > Private Sub CustomersDataGridView_RowValidated(ByVal sender As Object, > ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles > CustomersDataGridView.RowValidated > > CustomersDataGridView.FirstDisplayedScrollingRowIndex = > CustomersDataGridView.Rows.Count - 5 > > End Sub > > Susan H.