Home › Forums › WinForms controls › Xceed Grid for WinForms › Adding new row and editing it immidiately does not work
-
AuthorPosts
-
#12842 |
Hi people,
I have to admit that I am new with Xceed Grid, but one thing does not look quite logical:
I have a simple data-bound greed with two columns, bound on a dataset. The first column is bound to an autonumber field. The second column is bound to a text field.I have follwoing code associated with a button for adding new row and editing it immidiately:
// add the row
DataRow newrow = gridControl1.DataRows.AddNew();
newrow.EndEdit();//get the index
int ind = newrow.Index;//select the row
gridControl1.SelectedRows.Clear();
gridControl1.SelectedRows.Add(newrow);// scroll down
gridControl1.Scroll(ScrollDirection.BottomPage);
// start editing
newrow.Cells[“naziv”].EnterEdit();I also have another button on the form, with the following code, for updating the dataset:
oleDbDataAdapter1.Update(dataSetDrzave1);
dataSetDrzave1.AcceptChanges();When I click on a button to add the new row, it really appears as if it does what it should do – adds a new row in the grid, immidiately writes the next autonumber index in the first column and starts editing in the second column.
When I click the other (“save”) button, it really adds a new record in a table, but it is empty, even if I entered something in the grid?!
Heeeeeeelp please…
PS. Sorry for bad english (I’m not a native english speaker)
Greetings, Wina
Imported from legacy forums. Posted by winabike (had 3910 views)
Oh, I forgot to say: when I restart the application, and edit the field which was entred as blank before, and click “save button”, it works ok.
It means, editing of the fields works totaly ok, but adding & editing makes troubles (saves blank fields in the table)…
Imported from legacy forums. Posted by winabike (had 274 views)
Funny, funny..
It seams that hen you call EnterEdit method, change the value of the cell, and click somewhere else in the grid, the cell still stays in the edit mode?!
If you edit the cell with the doubleclick, everything works ok…
So the solution for the problem is to make some coding in ValueChanged event:
private void celldataRowTemplate1naziv_ValueChanged(object sender, System.EventArgs e)
{
Xceed.Grid.DataCell sndr = (Xceed.Grid.DataCell)sender;
bool celledited = sndr.IsBeingEdited;
if (celledited==true) sndr.ParentRow.EndEdit();
}Hope it helps somebody who comes to the same problem…
Imported from legacy forums. Posted by winabike (had 329 views)
Winabike,
It is best to call EndEdit on cells that are in EnterEdit state when you are done editing to invoke validation and saving.Imported from legacy forums. Posted by Vince [Xceed] (had 4359 views)
-
AuthorPosts
- You must be logged in to reply to this topic.