Solved

Datgrid row values to textfields

Posted on 2008-06-13
1
258 Views
Last Modified: 2010-04-30
I have a data grid that is populated with data froma MS Access table. I need to be able to click or double click a row in the datagrid then dispaly that inforamtion into the respective text boxes.

Example: The data grid shows the following:
           Product Number    Product Description                                                           Product Qty

I need the data from these three cells in the three respective text boxes. Where I take that dat and delete it from the table.
Thanks ahead of time.
0
Comment
Question by:gpdrahos
1 Comment
 
LVL 1

Accepted Solution

by:
Don VonderBurg earned 500 total points
ID: 21783082
Create a sub for your datagridview that has the event CellMouseClick. Then having 3 text boxes named like my example should work.
Private Sub MyDataGridView_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles MyDataGridView.CellMouseClick
' Just in case user clicked on the header
If e.RowIndex >= 0 Then
  ProductNumberTextBox.Text = MyDataGridView.Rows(e.RowIndex).Cells(0).Value.ToString
  ProductDescriptionTextBox.Text = MyDataGridView.Rows(e.RowIndex).Cells(1).Value.ToString
  ProductQtyTextBox.Text = MyDataGridView.Rows(e.RowIndex).Cells(2).Value.ToString
End If
 End Sub      

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question