Results 1 to 2 of 2

Thread: Perform actions on selected row in datagrid using button click.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2013
    Posts
    25

    Perform actions on selected row in datagrid using button click.

    Hello,

    I am using VB6 and have a question about datagrid controls.

    I have a datagrid on my form which will import data from a database on form load.

    The data in the grid are basically requests that need approval.

    I am looking for a way to highlight the row in the data grid and click on the button "Approve Requests" below.
    This button click event should change the status of the request from "pending" to "approved".

    I have a screenshot of my form attached.

    Any help on this would be greatly appreciated.
    Attached Images Attached Images  

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,484

    Re: Perform actions on selected row in datagrid using button click.

    If you click on a row, it will be highlighted.
    Then, if you capture one of the unique items (column) in that row that exists in your database (like ID, or some other unique identifier), it is easy to do an update of your database.
    You 'capture' that unique ID by setting the datagrid column to whichever one it appears in your grid.
    For example, if your grid had entries like this:
    Code:
    ID                    Item                              Approved?
    176                  Request for time off               No
    177                  Request for extra pay             No
    and you click on the second row. Then in the Button Click event set the grid's column to 0 (ie, datagrid1.col = 0), and then the datagrid1.Text value would be 176. Then simply update your db with an approval of 'Yes'.

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