Thanks to both of you for your replies.
The problem is that I'm not creating a new row programmatically then
filling it with values. Rather, the user is interacting with the "row
for new records" and I'm programmatically entering values into that row
based on what the user does.
If I were just trying to add a new record entirely through code, I
could easily see how this would be done using the underlying DataTable.
But, in this case, if I were to add a new row to the DataTable when the
user interacts with row for new records, It seems like I'd just end up
with two unsync'd versions of the same row.
I like the SendKeys idea, but it only works for tables where there is a
visible DataGridViewTextBoxCell available to send input to. Sending
keys to a DataGridViewButtonCell, for example, doesn't trick the
DataGridView into thinking the row has been edited.
Is there really no way to simply set the status of a row to
edited/changed?
There seems to be a way to set the DirtyState of a cell to True
(NotifyCurrentCellDirty), but this still isn't enough to prevent the
problem of all values disappearing when the row loses focus. I also
can't seem to programmatically change the CurrentCell to any other type
of cell besides a DataGridViewTextBoxCell.
Right now, the only solution I can think of is to create a dummy
DataGridViewTextBoxColumn in a every table just so that I can use
SendKeys with it. Someone please tell me I don't have to resort to
something that kludgey!
Thanks again,
-Dan
> One other comment in addition to what Ciaran suggested is that the row
> with the * next to it is the AddNew row so it really does not exist in
[quoted text clipped - 20 lines]
> Clay Burch
> Syncfusion, Inc.
RobinS - 25 Jan 2007 22:09 GMT
Why can't you create a new row for your datatable, and put the user's
entries into it, then add it to the DataGridView?
What are you binding your datagridview to? Is it by chance a list of
objects? Or is it a datatable or dataset?
Robin S.
---------------------------------
> Thanks to both of you for your replies.
>
[quoted text clipped - 68 lines]
>> Clay Burch
>> Syncfusion, Inc.
DanThMan - 26 Jan 2007 07:01 GMT
It looks like the solution was to place the following code in the
DataGridView'sRowLeave event handler:
'make sure row is not empty
'binding = reference to the binding for the DataGridView
binding.SuspendBinding()
binding.ResumeBinding()
I'd feel better about this if I knew why it worked. I just sort of
stumbled upon it after playing with several different solutions,
including using SendKeys and adding a row to the DataTable.
Thanks for all the advice,
-Dan
> Why can't you create a new row for your datatable, and put the user's
> entries into it, then add it to the DataGridView?
[quoted text clipped - 76 lines]
> >> Clay Burch
> >> Syncfusion, Inc.
William LaMartin - 26 Jan 2007 16:41 GMT
I have found that if I want to be sure that changes to a cell in a
datagridview are made that I need to click on any other row before doing the
update command for the dataadapter.
I am sure there is another way.
> It looks like the solution was to place the following code in the
> DataGridView'sRowLeave event handler:
[quoted text clipped - 92 lines]
>> >> Clay Burch
>> >> Syncfusion, Inc.