Solved

Datgrid row values to textfields

Posted on 2008-06-13
1
248 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:
dvonderburg earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now