Solved

Datgrid row values to textfields

Posted on 2008-06-13
1
253 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

821 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