473,698 Members | 2,086 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.D ataSource;
dataGridView1.D ataSource = null;
dataGridView1.D ataSource = 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 3224
ah, BindingList<T> is my friend!

"Steve" <ss*@sss.com> wrote in message
news:eb******** ******@TK2MSFTN GP15.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.D ataSource;
dataGridView1.D ataSource = null;
dataGridView1.D ataSource = 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9475
by: steve | last post by:
Hi All How can I get the datagridview to redraw after changing the rowtemplate.height at runtime ( it is databound to a datatable) I have tried datagridview1.refresh etc to no avail (The row height stays the same) If I repopulate its datasource (datatable) then the rows resize OK, but that is an uneccessary overhead.
0
3171
by: lv2compute | last post by:
I am having a problem with my datagridview. I have a small table that has two columns. The first column is bound to my dataset. The second column is a combobox. I add items to the combobox based on the information that I get from a text file. I then try to set the value of the combobox to a specific value based on the first column. The code is working to set the value, but it will not refresh and display the selected value on the screen...
3
7562
by: David Cartwright | last post by:
Hi all, I'm having a weird time with a call to the Refresh() method of a DataGridView. I have a VB.NET 2005 Windows application with a main form and a "worker" thread. The main form delegates a Sub to the worker so that the latter can refresh the DataGrid after updating the DataTable driving it. When I run the app under the debugger, everything's fine. But when I run it for real, it hangs, apparently in the Refresh() method of the...
2
15529
by: Steve Richter | last post by:
what is the best way to use DataGridView to view data from large database tables? Where the sql select statement might return millions of rows? string connectionString = GetFinancesConnString(); string sqlSelect = "select CheckNbr, CheckDate, CheckAmt from Disbursements" ; SqlDataAdapter adapter = new SqlDataAdapter(sqlSelect, connectionString);
0
2967
by: =?Utf-8?B?aW1yYW4uYQ==?= | last post by:
Hi all, I am having a problem with inserting rows in to my datagridview control. The datagridview is bound to a bindingsource with a filter set. If i try and add a row to the datagridview while the filter is set i get an IndexOutOfRangeException specifying that the index of the row i have just added does not exist. I have managed to narrow down the conditions that cause the error and it seems to surface if i have a filter set for a...
1
7781
by: Karl | last post by:
Hi all... This is a good one. You'll like this... I am working on a course management tool that allows certain Courses to be cross referenced with Job Roles and, when they are, whether the course is a priority course or not. Simple. Because there is alot of data stored for each course, I am using a tab control with several pages. The Job Role cross-referencing comes on
4
12168
by: Claudia Fong | last post by:
I need to add new rows into a datagridview manually.. but when I first added the new row I got an error of: No row can be added to a DataGridView control that does not have columns. Columns must be added first. But when I add the column I got this error: At least one of the DataGridView control's columns has no cell template. Can someone help me?
1
2813
by: Andrus | last post by:
I have Winforms DataGridView whose DataSource Rids is Marc sample TableListCollection<TRowderived from BindingList. It is used to edit invoice rows. If user presses Revert button, my application reads original rows from server database: List<TRowtr; tr = q.Where(r =r.Dokumnr == Dok.Dokumnr) .OrderBy(r =r.Reanr).ToList(); Rids = new TableListCollection<TRow>(Grid.RowTable, tr);
6
3215
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab through the new row being added. It does not 'Add' that row, nor setup the 'next blank add row' so I can continue to tab
0
8672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9018
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2322
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.