471,603 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

DataGridView not refreshing when new rows added

I have a bound DataGridView. When I add an item to the DataSource, the
DataGridView won't reflect the new row. I have googled and googled, no
solution that I have found online works. One thing that did work (sorta)
was this:
<code>
object tmp = dataGridView1.DataSource;
dataGridView1.DataSource = null;
dataGridView1.DataSource = tmp;
</code>

That is ugly code and I'm not happy about it. Another thing is that after I
run the above code, all the items are bound in the reverse order, isn't that
weird? ;)
Anyway, Refresh(), EndUpdate() Parent.Refresh() - none of that works. Is
this a known bug? Anyone have a trick?

Thanks,
Steve
Feb 18 '06 #1
1 3119
ah, BindingList<T> is my friend!

"Steve" <ss*@sss.com> wrote in message
news:eb**************@TK2MSFTNGP15.phx.gbl...
I have a bound DataGridView. When I add an item to the DataSource, the
DataGridView won't reflect the new row. I have googled and googled, no
solution that I have found online works. One thing that did work (sorta)
was this:
<code>
object tmp = dataGridView1.DataSource;
dataGridView1.DataSource = null;
dataGridView1.DataSource = tmp;
</code>

That is ugly code and I'm not happy about it. Another thing is that after
I run the above code, all the items are bound in the reverse order, isn't
that weird? ;)
Anyway, Refresh(), EndUpdate() Parent.Refresh() - none of that works. Is
this a known bug? Anyone have a trick?

Thanks,
Steve

Feb 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by lv2compute | last post: by
3 posts views Thread by David Cartwright | last post: by
2 posts views Thread by Steve Richter | last post: by
reply views Thread by =?Utf-8?B?aW1yYW4uYQ==?= | last post: by
4 posts views Thread by Claudia Fong | last post: by
1 post views Thread by Andrus | last post: by
6 posts views Thread by Miro | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.