Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Datagridview sort by default

gridview grid datagridview

  • Please log in to reply
No replies to this topic

#1 tennyis

tennyis

    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 13 February 2012 - 11:07 AM

I am working on an application for doing quotes for customers. I am using Visual basic 2008 and MS Access database. I have a form that displays all of the current customers. On load it loads tblCustomers into datagridview1. I can add, edit, delete, etc from the datagrid without issue.

I would however like it to sort by columb tblCustomer by default as soon as it is displayed. If I click on the column header then it sorts by that column. Seems like this should be an easy thing to do but I don't see any options. I have tried using "DataGridView1.Sort(DataGridView1.Columns(0))" in form load but to no avail, I am guessing the dgv is not populated yet at that point?

---------- Post added at 02:07 PM ---------- Previous post was at 02:02 PM ----------

ok I got that sorted out, I was missing the information to pass along what order to sort by. But now I am having a new issue. When I start to type in a new record, as soon as I type in the customer name and hit tab, it sorts it. So the list right now is about 150 clients, and if the new client starts with A it's going up to the top before I have a chance to put in the address, phone number, etc.
  • 0





Also tagged with one or more of these keywords: gridview, grid, datagridview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download