I can easily programmatically add a new row to a DataSet, fill the columns with the appropriate data and the new row is in the corresponding DataGridView is conveniently updated when the DataSet changes. Is there any way to do this in the other direction? That is, if the DateGridView is enabled to allow the user to add new rows by typing in the grid, is there some way to "push" this data back to the bound DataSet so that it stays in sync with the DataGridView. It doesn't appear to update the underlying database table when I do an Update on the data adapter. roy
Right, but if you make a change (i.e. add a row) by typing new data into the last row of the DataGridView, in my case, the data doesn't appear to be pushed into the bound DataSet. When I do an DataAdapter update (after building the insert, select, update, and delete commands) on the data set, some of the fields are null, even though they were filled in and the update of the database table fails, because a particular field is null (again, even though I set that column's date to a non-null value). [quoted text, click to view] Cor Ligthert [MVP] wrote: > Roy, > > The datagridview has not data part, it shows the data from the datasource, > which is pushed in that by a rowchange, a BindingSource.endedit or a > Currencymanager.endcurrentedit (the later two when that rowchange is not > done.) > > http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx > > > http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx > > I hope this helps, > > Cor > > <roybrew@att.net> schreef in bericht > news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... > >I can easily programmatically add a new row to a DataSet, fill the > > columns with the appropriate data and the new row is in the > > corresponding DataGridView is conveniently updated when the DataSet > > changes. Is there any way to do this in the other direction? That is, > > if the DateGridView is enabled to allow the user to add new rows by > > typing in the grid, is there some way to "push" this data back to the > > bound DataSet so that it stays in sync with the DataGridView. It > > doesn't appear to update the underlying database table when I do an > > Update on the data adapter. > > > > roy > >
What is the correct DataGridView event to invoke the "EndEdit" operation. It seems like many of the events (RowsAdded, UserAddedRow) are too early in the edit process to invoke the EndEdit. They seem to fire when I start typing in the first column of the new row. Invoking "EndEdit" at that point will take the cell out of edit mode, which is not the behavior I want. roy [quoted text, click to view] Cor Ligthert [MVP] wrote: > > Right, but if you make a change (i.e. add a row) by typing new data > > into the last row of the DataGridView, in my case, the data doesn't > > appear to be pushed into the bound DataSet. When I do an DataAdapter > > update (after building the insert, select, update, and delete commands) > > on the data set, some of the fields are null, even though they were > > filled in and the update of the database table fails, because a > > particular field is null (again, even though I set that column's date > > to a non-null value). > > And did you do one of those methods that I showed you in my last reply > before that update? > (Normally with 2.0 the bindingsource.endedit) > > Cor > > > > > > > Cor Ligthert [MVP] wrote: > >> Roy, > >> > >> The datagridview has not data part, it shows the data from the > >> datasource, > >> which is pushed in that by a rowchange, a BindingSource.endedit or a > >> Currencymanager.endcurrentedit (the later two when that rowchange is not > >> done.) > >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx > >> > >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx > >> > >> I hope this helps, > >> > >> Cor > >> > >> <roybrew@att.net> schreef in bericht > >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... > >> >I can easily programmatically add a new row to a DataSet, fill the > >> > columns with the appropriate data and the new row is in the > >> > corresponding DataGridView is conveniently updated when the DataSet > >> > changes. Is there any way to do this in the other direction? That is, > >> > if the DateGridView is enabled to allow the user to add new rows by > >> > typing in the grid, is there some way to "push" this data back to the > >> > bound DataSet so that it stays in sync with the DataGridView. It > >> > doesn't appear to update the underlying database table when I do an > >> > Update on the data adapter. > >> > > >> > roy > >> > > >
Never mind Cor. I figured it out. But you helped me "get there". When the RowLeave event gets fired, I check to make sure that my column index is my last column and if so, things work appropriately. What I have is a grid with 6 columns -- 4 of them hidden. Two of these are id columns (one a primary key) that I don't need to display. When I originally received the RowsAdded or UserAddedRow events, I believe it was too early in the edit cell process. I was pre-populating my hidden columns with "legal" values, but it was too soon. Now if I wait until the RowLeave event is fired AND my last column was just filled with data, this is the appropriate time to pre-populate these hidden columns I mentioned above. So as it turns out, I don't even need to invoke either of the "EndEdit" methods you mentioned. My database updates work fine now. Thanks for steering me down the right path. roy [quoted text, click to view] royb...@att.net wrote: > What is the correct DataGridView event to invoke the "EndEdit" > operation. It seems like many of the events (RowsAdded, UserAddedRow) > are too early in the edit process to invoke the EndEdit. They seem to > fire when I start typing in the first column of the new row. Invoking > "EndEdit" at that point will take the cell out of edit mode, which is > not the behavior I want. > > roy > > > > Cor Ligthert [MVP] wrote: > > > Right, but if you make a change (i.e. add a row) by typing new data > > > into the last row of the DataGridView, in my case, the data doesn't > > > appear to be pushed into the bound DataSet. When I do an DataAdapter > > > update (after building the insert, select, update, and delete commands) > > > on the data set, some of the fields are null, even though they were > > > filled in and the update of the database table fails, because a > > > particular field is null (again, even though I set that column's date > > > to a non-null value). > > > > And did you do one of those methods that I showed you in my last reply > > before that update? > > (Normally with 2.0 the bindingsource.endedit) > > > > Cor > > > > > > > > > > > Cor Ligthert [MVP] wrote: > > >> Roy, > > >> > > >> The datagridview has not data part, it shows the data from the > > >> datasource, > > >> which is pushed in that by a rowchange, a BindingSource.endedit or a > > >> Currencymanager.endcurrentedit (the later two when that rowchange is not > > >> done.) > > >> > > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx > > >> > > >> > > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx > > >> > > >> I hope this helps, > > >> > > >> Cor > > >> > > >> <roybrew@att.net> schreef in bericht > > >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... > > >> >I can easily programmatically add a new row to a DataSet, fill the > > >> > columns with the appropriate data and the new row is in the > > >> > corresponding DataGridView is conveniently updated when the DataSet > > >> > changes. Is there any way to do this in the other direction? That is, > > >> > if the DateGridView is enabled to allow the user to add new rows by > > >> > typing in the grid, is there some way to "push" this data back to the > > >> > bound DataSet so that it stays in sync with the DataGridView. It > > >> > doesn't appear to update the underlying database table when I do an > > >> > Update on the data adapter. > > >> > > > >> > roy > > >> > > > >
Ok thanks. I'm on the right track now.. [quoted text, click to view] Cor Ligthert [MVP] wrote: > Roy, > > I wrote "before you do that update". That procedure is the place where you > have to do it. > > And if you check in that for the haschanges than exactly before that. > > Otherwise show some code than we can see why it is not working for you. > > Cor > > <roybrew@att.net> schreef in bericht > news:1155588279.894979.231330@p79g2000cwp.googlegroups.com... > > What is the correct DataGridView event to invoke the "EndEdit" > > operation. It seems like many of the events (RowsAdded, UserAddedRow) > > are too early in the edit process to invoke the EndEdit. They seem to > > fire when I start typing in the first column of the new row. Invoking > > "EndEdit" at that point will take the cell out of edit mode, which is > > not the behavior I want. > > > > roy > > > > > > > > Cor Ligthert [MVP] wrote: > >> > Right, but if you make a change (i.e. add a row) by typing new data > >> > into the last row of the DataGridView, in my case, the data doesn't > >> > appear to be pushed into the bound DataSet. When I do an DataAdapter > >> > update (after building the insert, select, update, and delete commands) > >> > on the data set, some of the fields are null, even though they were > >> > filled in and the update of the database table fails, because a > >> > particular field is null (again, even though I set that column's date > >> > to a non-null value). > >> > >> And did you do one of those methods that I showed you in my last reply > >> before that update? > >> (Normally with 2.0 the bindingsource.endedit) > >> > >> Cor > >> > >> > > >> > > >> > Cor Ligthert [MVP] wrote: > >> >> Roy, > >> >> > >> >> The datagridview has not data part, it shows the data from the > >> >> datasource, > >> >> which is pushed in that by a rowchange, a BindingSource.endedit or a > >> >> Currencymanager.endcurrentedit (the later two when that rowchange is > >> >> not > >> >> done.) > >> >> > >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx > >> >> > >> >> > >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx > >> >> > >> >> I hope this helps, > >> >> > >> >> Cor > >> >> > >> >> <roybrew@att.net> schreef in bericht > >> >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... > >> >> >I can easily programmatically add a new row to a DataSet, fill the > >> >> > columns with the appropriate data and the new row is in the > >> >> > corresponding DataGridView is conveniently updated when the DataSet > >> >> > changes. Is there any way to do this in the other direction? That > >> >> > is, > >> >> > if the DateGridView is enabled to allow the user to add new rows by > >> >> > typing in the grid, is there some way to "push" this data back to > >> >> > the > >> >> > bound DataSet so that it stays in sync with the DataGridView. It > >> >> > doesn't appear to update the underlying database table when I do an > >> >> > Update on the data adapter. > >> >> > > >> >> > roy > >> >> > > >> > > >
Roy, The datagridview has not data part, it shows the data from the datasource, which is pushed in that by a rowchange, a BindingSource.endedit or a Currencymanager.endcurrentedit (the later two when that rowchange is not done.) http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx I hope this helps, Cor <roybrew@att.net> schreef in bericht news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... [quoted text, click to view] >I can easily programmatically add a new row to a DataSet, fill the > columns with the appropriate data and the new row is in the > corresponding DataGridView is conveniently updated when the DataSet > changes. Is there any way to do this in the other direction? That is, > if the DateGridView is enabled to allow the user to add new rows by > typing in the grid, is there some way to "push" this data back to the > bound DataSet so that it stays in sync with the DataGridView. It > doesn't appear to update the underlying database table when I do an > Update on the data adapter. > > roy >
[quoted text, click to view] > Right, but if you make a change (i.e. add a row) by typing new data > into the last row of the DataGridView, in my case, the data doesn't > appear to be pushed into the bound DataSet. When I do an DataAdapter > update (after building the insert, select, update, and delete commands) > on the data set, some of the fields are null, even though they were > filled in and the update of the database table fails, because a > particular field is null (again, even though I set that column's date > to a non-null value).
And did you do one of those methods that I showed you in my last reply before that update? (Normally with 2.0 the bindingsource.endedit) Cor [quoted text, click to view] > > > Cor Ligthert [MVP] wrote: >> Roy, >> >> The datagridview has not data part, it shows the data from the >> datasource, >> which is pushed in that by a rowchange, a BindingSource.endedit or a >> Currencymanager.endcurrentedit (the later two when that rowchange is not >> done.) >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx >> >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx >> >> I hope this helps, >> >> Cor >> >> <roybrew@att.net> schreef in bericht >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... >> >I can easily programmatically add a new row to a DataSet, fill the >> > columns with the appropriate data and the new row is in the >> > corresponding DataGridView is conveniently updated when the DataSet >> > changes. Is there any way to do this in the other direction? That is, >> > if the DateGridView is enabled to allow the user to add new rows by >> > typing in the grid, is there some way to "push" this data back to the >> > bound DataSet so that it stays in sync with the DataGridView. It >> > doesn't appear to update the underlying database table when I do an >> > Update on the data adapter. >> > >> > roy >> > >
Roy, I wrote "before you do that update". That procedure is the place where you have to do it. And if you check in that for the haschanges than exactly before that. Otherwise show some code than we can see why it is not working for you. Cor <roybrew@att.net> schreef in bericht news:1155588279.894979.231330@p79g2000cwp.googlegroups.com... [quoted text, click to view] > What is the correct DataGridView event to invoke the "EndEdit" > operation. It seems like many of the events (RowsAdded, UserAddedRow) > are too early in the edit process to invoke the EndEdit. They seem to > fire when I start typing in the first column of the new row. Invoking > "EndEdit" at that point will take the cell out of edit mode, which is > not the behavior I want. > > roy > > > > Cor Ligthert [MVP] wrote: >> > Right, but if you make a change (i.e. add a row) by typing new data >> > into the last row of the DataGridView, in my case, the data doesn't >> > appear to be pushed into the bound DataSet. When I do an DataAdapter >> > update (after building the insert, select, update, and delete commands) >> > on the data set, some of the fields are null, even though they were >> > filled in and the update of the database table fails, because a >> > particular field is null (again, even though I set that column's date >> > to a non-null value). >> >> And did you do one of those methods that I showed you in my last reply >> before that update? >> (Normally with 2.0 the bindingsource.endedit) >> >> Cor >> >> > >> > >> > Cor Ligthert [MVP] wrote: >> >> Roy, >> >> >> >> The datagridview has not data part, it shows the data from the >> >> datasource, >> >> which is pushed in that by a rowchange, a BindingSource.endedit or a >> >> Currencymanager.endcurrentedit (the later two when that rowchange is >> >> not >> >> done.) >> >> >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx >> >> >> >> >> >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx >> >> >> >> I hope this helps, >> >> >> >> Cor >> >> >> >> <roybrew@att.net> schreef in bericht >> >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... >> >> >I can easily programmatically add a new row to a DataSet, fill the >> >> > columns with the appropriate data and the new row is in the >> >> > corresponding DataGridView is conveniently updated when the DataSet >> >> > changes. Is there any way to do this in the other direction? That >> >> > is, >> >> > if the DateGridView is enabled to allow the user to add new rows by >> >> > typing in the grid, is there some way to "push" this data back to >> >> > the >> >> > bound DataSet so that it stays in sync with the DataGridView. It >> >> > doesn't appear to update the underlying database table when I do an >> >> > Update on the data adapter. >> >> > >> >> > roy >> >> > >> > >
Roy, Good you found it, but mostly are the grid events not the most proper place to do things it. You can use the currencymanager postionchange event in most situations much easier. http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingmanagerbase.positionchanged.aspx Maybe for the next time Cor <roybrew@att.net> schreef in bericht news:1155588851.099050.114640@h48g2000cwc.googlegroups.com... [quoted text, click to view] > Never mind Cor. I figured it out. But you helped me "get there". > When the RowLeave event gets fired, I check to make sure that my column > index is my last column and if so, things work appropriately. What I > have is a grid with 6 columns -- 4 of them hidden. Two of these are id > columns (one a primary key) that I don't need to display. When I > originally received the RowsAdded or UserAddedRow events, I believe it > was too early in the edit cell process. I was pre-populating my hidden > columns with "legal" values, but it was too soon. Now if I wait until > the RowLeave event is fired AND my last column was just filled with > data, this is the appropriate time to pre-populate these hidden columns > I mentioned above. So as it turns out, I don't even need to invoke > either of the "EndEdit" methods you mentioned. My database updates > work fine now. Thanks for steering me down the right path. > > roy > > > > royb...@att.net wrote: >> What is the correct DataGridView event to invoke the "EndEdit" >> operation. It seems like many of the events (RowsAdded, UserAddedRow) >> are too early in the edit process to invoke the EndEdit. They seem to >> fire when I start typing in the first column of the new row. Invoking >> "EndEdit" at that point will take the cell out of edit mode, which is >> not the behavior I want. >> >> roy >> >> >> >> Cor Ligthert [MVP] wrote: >> > > Right, but if you make a change (i.e. add a row) by typing new data >> > > into the last row of the DataGridView, in my case, the data doesn't >> > > appear to be pushed into the bound DataSet. When I do an DataAdapter >> > > update (after building the insert, select, update, and delete >> > > commands) >> > > on the data set, some of the fields are null, even though they were >> > > filled in and the update of the database table fails, because a >> > > particular field is null (again, even though I set that column's date >> > > to a non-null value). >> > >> > And did you do one of those methods that I showed you in my last reply >> > before that update? >> > (Normally with 2.0 the bindingsource.endedit) >> > >> > Cor >> > >> > > >> > > >> > > Cor Ligthert [MVP] wrote: >> > >> Roy, >> > >> >> > >> The datagridview has not data part, it shows the data from the >> > >> datasource, >> > >> which is pushed in that by a rowchange, a BindingSource.endedit or a >> > >> Currencymanager.endcurrentedit (the later two when that rowchange is >> > >> not >> > >> done.) >> > >> >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx >> > >> >> > >> >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx >> > >> >> > >> I hope this helps, >> > >> >> > >> Cor >> > >> >> > >> <roybrew@att.net> schreef in bericht >> > >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... >> > >> >I can easily programmatically add a new row to a DataSet, fill the >> > >> > columns with the appropriate data and the new row is in the >> > >> > corresponding DataGridView is conveniently updated when the >> > >> > DataSet >> > >> > changes. Is there any way to do this in the other direction? >> > >> > That is, >> > >> > if the DateGridView is enabled to allow the user to add new rows >> > >> > by >> > >> > typing in the grid, is there some way to "push" this data back to >> > >> > the >> > >> > bound DataSet so that it stays in sync with the DataGridView. It >> > >> > doesn't appear to update the underlying database table when I do >> > >> > an >> > >> > Update on the data adapter. >> > >> > >> > >> > roy >> > >> > >> > > >
Ok thanks. [quoted text, click to view] Cor Ligthert [MVP] wrote: > Roy, > > Good you found it, but mostly are the grid events not the most proper place > to do things it. > > You can use the currencymanager postionchange event in most situations much > easier. > > http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingmanagerbase.positionchanged.aspx > > Maybe for the next time > > Cor > > <roybrew@att.net> schreef in bericht > news:1155588851.099050.114640@h48g2000cwc.googlegroups.com... > > Never mind Cor. I figured it out. But you helped me "get there". > > When the RowLeave event gets fired, I check to make sure that my column > > index is my last column and if so, things work appropriately. What I > > have is a grid with 6 columns -- 4 of them hidden. Two of these are id > > columns (one a primary key) that I don't need to display. When I > > originally received the RowsAdded or UserAddedRow events, I believe it > > was too early in the edit cell process. I was pre-populating my hidden > > columns with "legal" values, but it was too soon. Now if I wait until > > the RowLeave event is fired AND my last column was just filled with > > data, this is the appropriate time to pre-populate these hidden columns > > I mentioned above. So as it turns out, I don't even need to invoke > > either of the "EndEdit" methods you mentioned. My database updates > > work fine now. Thanks for steering me down the right path. > > > > roy > > > > > > > > royb...@att.net wrote: > >> What is the correct DataGridView event to invoke the "EndEdit" > >> operation. It seems like many of the events (RowsAdded, UserAddedRow) > >> are too early in the edit process to invoke the EndEdit. They seem to > >> fire when I start typing in the first column of the new row. Invoking > >> "EndEdit" at that point will take the cell out of edit mode, which is > >> not the behavior I want. > >> > >> roy > >> > >> > >> > >> Cor Ligthert [MVP] wrote: > >> > > Right, but if you make a change (i.e. add a row) by typing new data > >> > > into the last row of the DataGridView, in my case, the data doesn't > >> > > appear to be pushed into the bound DataSet. When I do an DataAdapter > >> > > update (after building the insert, select, update, and delete > >> > > commands) > >> > > on the data set, some of the fields are null, even though they were > >> > > filled in and the update of the database table fails, because a > >> > > particular field is null (again, even though I set that column's date > >> > > to a non-null value). > >> > > >> > And did you do one of those methods that I showed you in my last reply > >> > before that update? > >> > (Normally with 2.0 the bindingsource.endedit) > >> > > >> > Cor > >> > > >> > > > >> > > > >> > > Cor Ligthert [MVP] wrote: > >> > >> Roy, > >> > >> > >> > >> The datagridview has not data part, it shows the data from the > >> > >> datasource, > >> > >> which is pushed in that by a rowchange, a BindingSource.endedit or a > >> > >> Currencymanager.endcurrentedit (the later two when that rowchange is > >> > >> not > >> > >> done.) > >> > >> > >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.endedit.aspx > >> > >> > >> > >> > >> > >> http://msdn2.microsoft.com/en-us/library/system.windows.forms.currencymanager.endcurrentedit.aspx > >> > >> > >> > >> I hope this helps, > >> > >> > >> > >> Cor > >> > >> > >> > >> <roybrew@att.net> schreef in bericht > >> > >> news:1155584017.136717.68480@i3g2000cwc.googlegroups.com... > >> > >> >I can easily programmatically add a new row to a DataSet, fill the > >> > >> > columns with the appropriate data and the new row is in the > >> > >> > corresponding DataGridView is conveniently updated when the > >> > >> > DataSet > >> > >> > changes. Is there any way to do this in the other direction? > >> > >> > That is, > >> > >> > if the DateGridView is enabled to allow the user to add new rows > >> > >> > by > >> > >> > typing in the grid, is there some way to "push" this data back to > >> > >> > the > >> > >> > bound DataSet so that it stays in sync with the DataGridView. It > >> > >> > doesn't appear to update the underlying database table when I do > >> > >> > an > >> > >> > Update on the data adapter. > >> > >> > > >> > >> > roy > >> > >> > > >> > > > >
Don't see what you're looking for? Try a search.
|