Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing a serious issue with a lookup window, Please help to solve this.

see the steps of my form opens

1. Opens first form (from Dashboard)

Dim ObjOrder As New OrderFormFrm
ObjOrder.USER = USER
ObjOrder.Show()

Next I have to open a popwindow based on a textbox event.

Private Sub txtCustCode_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtCustCode.MouseClick

Dim PopUpCustomer As New searchCustomerfrm
PopUpCustomer.ShowDialog()
End Sub

3. I have to goback to Orderform with a value based on a gridview row click event

Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick

OrderFormFrm.txtCustCode.Text = Val(DGVCustomer.Item(1, e.RowIndex).Value)`

Me.Close()

End Sub

The problems is, I am getting value to Orderform's textbox when I start project form from 'OrderFormFrm' (project properties setting-start form), and not getting if I started project from the dashboard.

I need to display the value 'DGVCustomer.Item(1, e.RowIndex).Value' in Order forms text box 'txtCustCode'

Please help to solve this
Posted

1 solution

Solved this by a friend,

I could make a shared function on the searchCustomerfrm form that returns the value that you expect from the form:

Public Shared Function GetCustomer()
Dim PopUpCustomer As New searchCustomerfrm
If PopUpCustomer.ShowDialog() = DialogResult.OK Then
Return Val(PopUpCustomer.DGVCustomer.Item(1, PopUpCustomer.DGVCustomer.CurrentRow.Index).Value)
Else
Return Nothing
End If
End Function

ASM
On the DGVCustomer_CellContentDoubleClick write this:

Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick

    Me.DialogResult = DialogResult.OK

End Sub


VB
To call the searchCustomerfrm from OrderFormFrm:

txtCustCode.Text = searchCustomerfrm.GetCustomer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900