Results 1 to 4 of 4

Thread: [2005] Insert value from textbox into datagridview? Code included

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    184

    [2005] Insert value from textbox into datagridview? Code included

    I have a list box that is populated with data. When an item from the listbox is double clicked, the value is displayed in a textbox on the form. With the click of the "Change" button, I want to push that textbox value to index 4 in my DGV. Here is what I tried with no luck.

    This all occurs on the click event of the Change Button

    PHP Code:
    For Each row As DataGridViewRow In Form1.GroupDataList.SelectedRows
         row
    .Cells(5).Value txtSearch.Text
    Next 
    Any ideas why this wouldn't work?

    I don't get any errors, but nothing happens either.

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

    Re: [2005] Insert value from textbox into datagridview? Code included

    Are there any rows selected in the grid? If you want the cell at index 4 set then why are you specifying index 5 for the column?
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Posts
    184

    Re: [2005] Insert value from textbox into datagridview? Code included

    Oops, that was a typo. THe first part was also supposed to be "5". Yes, in the DGV it is returning one record, and I select that row.

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

    Re: [2005] Insert value from textbox into datagridview? Code included

    My guess is that you're referring to the wrong Form1 instance in your For loop. You're referring to the default instance. If you haven't displayed the default instance then you won't see the change. If this code is in the form itself then you should use Me, not Form1.
    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