Click here to Skip to main content
15,066,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
With the help of some youtube videos, I was able to retrieve and display data from the database into the listview. Now my problem is:

I want to click 1 row in the listview and when I click the edit/view button the data from that row would be inserted into those textboxes, comboboxes, etc.

Basically, I want to select a row and view it in another form.

What I have tried:

I used this code to view the data from the database into the listview:

<pre> private void loadtblsupp()
            cmd.CommandText = "select * from SupplierTable";
            cmd.Connection = cn;
            dr = cmd.ExecuteReader();
            while (dr.Read())
                ListViewItem item = new ListViewItem(dr["Supp_ID"].ToString());
Updated 27-May-18 21:58pm

1 solution

Exactly how depends on the "relationship" between the two forms.
Have a look at these, one of them will fit your circumstances.
The form that creates an instance of another:
MyForm mf = new MyForm();
Is the "parent", the other form is the "child".
(This doesn't imply any formal MDI relationship)

Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]

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