Results 1 to 2 of 2

Thread: [2005] datagridview select index 0 on click

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    258

    [2005] datagridview select index 0 on click

    on button click how do i set the selected index of the data grid to the first record? tnxxxx

    also..

    how do i set it so that when i click a specific row on a datagrid it would then be selected by the codes?

    coz i have a grid and to delete records from it i need to click on a row
    Last edited by aerialz666; Aug 28th, 2007 at 03:15 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] datagridview select index 0 on click

    Firstly, I would ask that you stop using the term "datagrid" if you're using a DataGridView. The DataGrid is a different control so you cannot use the two names interchangeably. If you do then it's only a matter of time until someone provides advice for a DataGrid that is irrelevant for a DataGridView.

    As to your first question, if your grid is bound then you should be using a BindingSource. In that case you simply set the Position property of the BindingSource to 0. That makes the first item the Current item and will thus select it in any bound controls.

    Your second question I don't understand at all. When you click on a row in the grid it is selected, so why would you need code to do it?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width