views:

2375

answers:

3

Hi, i have a Problem with DataGridView in c# and i hope you can help me :) I added a DataGridView to my Application and bind it to DataTable. The DataTable changing the content but the DataGridView doesnt display it... How can i change this ? Thanks

A: 

Did you try DataGridView.Refresh()?

Khadaji
yes i do but no result :(
subprime
+3  A: 

Is the data changing at the source, or within the application?

If the data is changing at the source, then I think the issue may be that .Net by default supports a disconnected data paradigm which is different from using a permanently connected model. Once the data is retrieved from the server, the client is no longer connected unless you go and get the data again. For example, if you're using a TableAdapter, you'd have to periodically call the DataAdapter.Fill() command to retrieve the data from the server.

If the data is changing in your app based on user interaction, then possibly DataDable.AcceptChanges() followed by Application.DoEvents()?

David Stratton
Note that if you're periodically polling the datasource, it's going to interrupt users who are using the application. You'd have to work around that,
David Stratton
I'm working only with DataSet in my application. A function read some data from file and put them into DataTable x if this done i try to refresh the DataGridView but nothing happen :(
subprime
OK, then it's changing in the app... And I'm assuming you've just set the DataGridView's source to the DataTable and as you're adding records to the DataTable, the DataGridView is not refreshing.. I'm assuming this is a WinForms application and not ASP.Net, because the DataGridView is specific to WinForms... Did you try DataDable.AcceptChanges() followed by Application.DoEvents()? or possibly setting the DataGridView's DataSource again in the function that reads from the text file, then Application.DoEvents()?
David Stratton
i've tried DataDable.AcceptChanges() followed by Application.DoEvents() but no changes and added a brakepoint. i can see that the data is in the datatable...its not possible to add this in the function
subprime
A: 

grid.dataBind()