Solved

Datgrid row values to textfields

Posted on 2008-06-13
1
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 41
clicking a shape in a frame array vb6 3 48
Formula problem with Excel attachment 6 43
Error with a code discussed on this page 5 38
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

761 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