DataGridView Problem

W

Wayne Gibson

Hi,
Was wonderingif anyone could help with the following problem..

I have a datagrid that I am populating from a datatable. The grid has a
number of columns, one of which is an DataGridViewTextBox Column. There
isn't a way to pick up when this column is updated.

So I'm using the CellBeginEdit and CellEndEdit events, to pick when a change
has been made. Now if the value in the text box
has changed, I need to refresh the DataGridView.

Which I'm doing by querying the database, then attaching the datatable to
the DataGridView.datasource. Now this works fine if :
1) The user is navigating around the DataGridView
2) The user clicks on another cell that doesn't have any controls in the
columns.

But if the user clicks on the another textbox in the same column, it throws
up an exception:

An unhandled exception of type 'System.InvalidOperationException' occurred
in System.Windows.Forms.dll
Additional information: Operation is not valid because it results in a
reentrant call to the SetCurrentCellAddressCore function.

Was wondering if anybody had an ideas on this?
Or if they could suggest a better way of refreshing the datasource outside
of CellEndEdit.

Thanks
 
K

Kevin Spencer

I'm confused.

First, you say that when you change a value in a cell, you must "refresh"
the DataGridView. Why?

Second, to refresh the DataGridView, you say that you "attach" a DataTable
to the DataGridView. What do you mean by "attach?"

Are you using any BindingSource? Is the DataGridView initially populated
from a data store? If so, how?

You should *not* need to "refresh" your DataGridView. But with the small
amount of information you've provided, I can't figure out what your
requirements are, what it is you're starting with, or what you're trying to
accomplish with your tactic. Can you elaborate?

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top