Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a winform in my C# application. This winform has some controls, a send button and list view to display values. I have internal logic which sends a request and the retrieved values are displayed in the list view. So If I open the form, send request and the values are enlisted in the listview of the form. This form is left open. When another instance of the form is open, request is sent, the values are retrieved but the values are getting displayed in the listview of the first instance of the form. How can I fix this?
Posted
Comments
Marcin Kozub 26-Mar-14 5:35am    
Please share your code.

1 solution

Depends on your code, which we can't see: but somewhere, you are transferring information to the wrong instance.

When you create a new instance of a form, you need to use that new instance to "fill in" the information. At a guess - and that's all it can be without your code - you are using a static variable to hold information, or you are referring to a single instance via a variable rather than using the "new" one.

Start with the code that retrieves the values: where is it? "Parent" form? or "Child" form? How do you access the form in that code?
What do you do when you create a new form? is it along the lines of:
C#
MyNewForm f = new MyNewForm();
FillInFormInformation();
f.Show();
If so, then you probably need to add a parameter to FillInFormInformation that allows you to pass "f"

But we can't tell, not from here. So you need to start looking!
 
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