last day (14 days later) » 

12:03 PM
0
A: C# datagridview adding extra items not showing up

SajeetharanYou need to call refresh() once you update, this.dataGridView2.DataSource = data; dataGridView2.update(); dataGridView2.refresh();

 
That didn't work. Results are the same.
 
@Thijser It should work, did you set the datasource to null before setting the new values?
 
No I just set it, I even straight up copied over your code (except I capitalised the Update and Refresh)
 
@Thijser can you give me team viewer?
 
I prefer not, I also have a very limited data capacity right now. But I can upload some screenshots
 
12:03 PM
@Thijser ok np:) add a debug window and check if the new items are added
 
does your datagrid display 2 items?
 
No
 
do this, this.dataGridView2.DataSource = null;
add this line before setting data
 
ok that works, why does that work?
Setting a variable to null before changing it shouldn't do anything right?
 
12:11 PM
when you set a new datasource
you need to clear the existing values
unless you are doing two way binding
did it help?
 
somewhat but it still doesn't really make sense to me from a language/library design perspective
But thanks a lot!
 
Can you mark it as answer?
??
 
ok can you add in that I have to set the datasource to null first?
 
i have added
 
OK thanks
 
12:19 PM
Thanks, where are you from?
nice to meet
bye tc
 

last day (14 days later) »