Click here to Skip to main content
15,891,852 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have 2 forms each has a gridview in it. So how could i show cell values of second grid form into the first grid form using the cellclick of the second datagridview ?
Posted
Comments
Abdul Quader Mamun 8-Feb-11 0:44am    
Second grid of form must be active. How can you active two form at a time?
Sergey Alexandrovich Kryukov 8-Feb-11 1:32am    
No, it does not matter. Active form is only needed to accept user input.
--SA

Passing Data Between Forms[^] might help you.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 1:25am    
Sorry, I didn't like the article at all. Not a nice coding style; methods are listed without explaining pro/contra. Important and best method is missing: interfaces.
--SA
Sergey Alexandrovich Kryukov 8-Feb-11 1:31am    
However, the topic itself is miserable, so you would not expect anything great anyway. MVC, MVP, MVVM does not have such problems; and even minimal applications can be organized the way that forms do not know each other but work with more abstract conceptual entities.
--SA
Abhinav S 8-Feb-11 2:25am    
Good point!
Declare a global public variable in form 2.

C#
public String abc;


In form one cell click event set gbloabl variable value and set it grid value of second form.
C#
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Form2 form2 = new Form2();
            form2.abc = "GridCellValue";
            //set abc value to grid
            form2.Show();

        }


Thanks,
Mamun
 
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