I have a datagridview on one form that present companyID, CompanyName and CompanyLocation from my database and want my users to select one row and duble click on it to open another form where the data will be presented in textboxes.
Right now the datagridview is read only and Selection mode is Full row select
I want something like this
If user D.klick Row with CompanyID 3 then
Open Form2 and populate txtCompanyID with companyID 3, txtCompanyName with Companyname where companyID is 3 and so on.
I appreciate any help I can get.
/Rikard
aka Biocide

Send data to form based on selection in datagridview
Dasa
Hi
This should do the trick:
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick If e.RowIndex < 0 Then ' If the column headers are clicked exit sub Exit Sub End If With DataGridView1.CurrentRowm_Accountno =
CStr(.Cells("accountno").Value) '//Two ways of passing the value of the select rows field value to a variablem_orderID = .Cells(3).Value
End Withdim objForm2 as new form2(m_accountno) '//Create instance of form2 passing in to its overloaded constructor m_accountno)
End sub
Within Form2 add the following code:
Public sub new (byval account as string)
me.textbox1.text= account
end sub
flash.tato
Timothy Wilson
I have one warning that i cant get rid of
Here is my code
Form named HanteraForetag
Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim m_orderID If e.RowIndex < 0 Then Exit Sub End If With DataGridView1.CurrentRowm_orderID = .Cells(0).Value
End With Dim objForm2 As New Form2(m_orderID) End SubCode on Form2
Public
Class Form2 Public Sub New(ByVal ForetagID As String) Me.TextBox1.Text = ForetagID End SubEnd
ClassThen i get this Warning
Warning 1 'Public Sub New(account As String)' in designer-generated type 'SoulemateX.Form2' should call InitializeComponent method. C:\Users\Rikard\Documents\Visual Studio 2005\Projects\SoulemateX\SoulemateX\Form2.vb 2 16 SoulemateX
Chuckster123
Taylor Meek
Hi ron nash and thanks for youre answer
Do you think you can explain this part for me
With DataGridView1.CurrentRow
m_Accountno = CStr(.Cells("accountno").Value) '//Two ways of passing the value of the select rows field value to a variable
m_orderID = .Cells(3).Value
End With
Ludo-R
Hi,
Add InitializeComponent() to the constructor
Public Sub New(ByVal ForetagID As String)
InitializeComponent()
Me.TextBox1.Text = ForetagID End Sub