Pass parameter back to datagrid from one form to another form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Melson

    Pass parameter back to datagrid from one form to another form

    Hi

    Can anyone help me with this problem. I've a form1(entry form) with datagrid
    which bound to a dataset (datagrid.setda tabinding(datas et,"table")). I've a
    public class Capturekey in form1 which capture key entered in the datagrid
    cell. I've another form2(product code form) which has a listview display
    product code.

    My problem is how can I pass the product code and product description in
    form2 back to form1 datagrid current cell.



    I manage to get the datagrid currentcell row and column with following code.
    datagrid.curren tcell.rownumber () and datagrid.curren tcell.columnnum ber()

    I've created a Public Sub AssignValue() in form1 with following clode.
    Public Sub AssignValue()
    datagrid.item(d atagrid.current cell.rownumber,
    datagrid.curren tcell.columnnum ber) = "test"
    End Sub

    In Public Class Capturekey, I've the following code.
    Public Class Capturekey
    dim newform1 as new form1
    newform1.Assign Value
    end class

    However, I got the following error, "Data cannot be read from a DataGrid
    which is not bound to a DataTable". Though the datagrid current row and
    column have value example 1.

    If I run the Public Sub AssignValue() in form1, not from other class like
    Public Class Capturekey, I can assign the value to the datagrid current cell
    successfully. I think the problem is the Public Sub New() in #Region
    "Windows Form Designer generated code" in form1 will always run when I
    declare Dim newform as new form1.

    Now I've 3 classes. I try not to merge form1 with Public Class Capturekey
    code because I would like to reuse Public Class Capturekey. Any better
    solution will be very appreciated. Pls help. Thanks

    Regards
    Melson


Working...