MF
Mauro Fiore
November 1, 2004 05:54 AM UTC
Excuse me,
idem happen if I click a barItem to insert a new row in DataTable, i.e:
private void mnuItem_Nuovo()
{
// svuoto input del form
EmptyForm();
// elimino messaggi di errore
ClearErrorControl();
// eseguo inserimento
PerformAppend();
// mi posizione su input
txtGruppoNome.Focus();
}
private void PerformAppend()
{
// aggiungo nuovo record
xRowGruppo = cGruppo.Table_Gruppi.NewRow_Gruppo();
txtGruppoID.Text = xRowGruppo.GruppoID.ToString();
EmptyRecord(cGruppo.Table_Gruppi.TableName);
// aggiungo riga alla collezione
cGruppo.Table_Gruppi.Add_dRow_Gruppo(xRowGruppo);
// aggiorno record count
cGruppo.CurrentCursor = cGruppo.Table_Gruppi.Rows.Count - 1;
...
}
Thanks again,
Mauro
AD
Administrator
Syncfusion Team
November 1, 2004 06:27 AM UTC
I am sorry, I do not understand your last post. Are you saying that the code posted in the last post works OK from a menu item?
I suspect it is the code in the CurrentCellChanged handler that is causing teh problem in your first post. Try commenting it out to see if the problem goes away when you do. If it does go away, then you can put a
if(!grid.Binder.IsAddNew)
check around the code in that handler to avoid hitting it for the AddNew row as the AddNew row is really not sent back to teh DataSource until you leave it.
MF
Mauro Fiore
November 2, 2004 04:38 AM UTC
Hi clay,
NO the 2nd post is the continuance of the attach file of the 1st post.
That is all I send (in the two posts)is how I deal in GDBG events or private methods.
How I tried to explain in the 1st post I don''t try to insert or modify records.
Every time I place the mouse in the new row to the bottom grid, the one reset all rows and I dont'' understand how happen.
Thanks,
Mauro
AD
Administrator
Syncfusion Team
November 2, 2004 06:14 AM UTC
Here is a sample where I posted your code into a simple form project. The only problem I see is that you are setting the GridBoundColumns after you set the grid''s DataSource. If you do it in this order, then after setting the GridBoundColumns, you need to call grid.Binder.InitializeColumns to make sure the grid is using the proper GridBoundColumns.
How do I see the problem you are having in this sample?
WindowsApplication4_1103.zip
MF
Mauro Fiore
November 2, 2004 07:12 AM UTC
Clay as you know you''re a great man,
now it seem to function, but unluckily
I don''t finish.
1. what is it Binder class, where can I find informations ?
2. how can I know the table.ColumName on the currentCell ( ex: gridDataBoundGrid1.TableStyles[cGruppo.DefaultTable].GridColumnStyles[x].MappingName)
3. how can I Reject or Cancel the new inserted row, by the grid and the dataset?
Hi, and very thanks
Mauro
apologize me for my bad english and my incapacity to explain things.
MF
Mauro Fiore
November 2, 2004 07:23 AM UTC
Clay, again excuse me
but after I inserted a new row and close the windows, the updatings didn''t take place in the dataset ?
What must I do ?
Hi, Mauro
AD
Administrator
Syncfusion Team
November 2, 2004 07:38 AM UTC
1) Binder is a GridModelDataBinder object which is a helper class that manages data binding for teh GridDataBoundGrid. Here is the help link in the class reference for this class.
ms-help://MS.VSCC.2003/Syncfusion.Essential_Suite/Syncfusion.EssentialSuiteClassRefWindows/Syncfusion.EssentialGridWindows/Syncfusion.EssentialGridWindows/Syncfusion.Grid.Windows~Syncfusion.Windows.Forms.Grid.GridModelDataBinder.html
2)
int col = this.grid.CurrentCell.ColIndex;
int field = this.grid.Binder.ColIndexToField(col);
string colName = this.grid.GridBoundColumns[field].MappingName;
3) It depend on exactly where/when you want to cancel the addnew. If you are doing it from the grid.RowLeave event, you can use code like:
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
if(this.gridDataBoundGrid1.Binder.IsAddNew)
{
//if you want to cancel the addnew
this.gridDataBoundGrid1.CurrentCell.CancelEdit();
this.gridDataBoundGrid1.Binder.CancelEdit();
}
}
MF
Mauro Fiore
November 2, 2004 08:37 AM UTC
Clay, again excuse me
but after I inserted a new row and close the windows, the updatings didn''t take place in the dataset
either I moving the row cursor or clicking a buttom ?
What must I do ?
And furthermore if I Reject or Cancel a row from a Buttom ?
Hi, Mauro
AD
Administrator
Syncfusion Team
November 2, 2004 08:57 AM UTC
1) To save the ADO.NET locally cached changes to a DataSet back to the DataBase, you will need to call your dataAdapter.Update method.
2) Make sure the button1.CausesValidation = false. Then try this code:
private void button1_Click(object sender, System.EventArgs e)
{
if(this.gridDataBoundGrid1.Binder.IsAddNew)
{
this.gridDataBoundGrid1.Focus();
this.gridDataBoundGrid1.CurrentCell.EndEdit();
this.gridDataBoundGrid1.Binder.CancelEdit();
}
}
MF
Mauro Fiore
November 3, 2004 06:58 AM UTC
HI Clay,
I''am here again. Unluckily I am not able to pull out a spider by the hole
(it''s a proverb of our zone) and I am to ask you if you can modify the simple attach project to understand what I must to do.
That I wish to do is to execute every operation both the botton object and the GDBG.
Thanks of all and apologize me.
Mauro
WindowsApplication1_8881.zip
AD
Administrator
Syncfusion Team
November 3, 2004 09:51 AM UTC
There is a column in your datatable that is not in the grid which is marked as being required in the Access db. So, there is no way for you to set this value using the grid since it is not in displayed. So, I was able to get the saving to workby populating this field directly in the DataTable in the grid.RowSaved event using this code.
private void gridDataBoundGrid1_RowSaved(object sender, GridRowEventArgs e)
{
if(e.RowIndex == this.gridDataBoundGrid1.Model.RowCount-1)
this.dataset11.Tables["B_Gruppi"].Rows[e.RowIndex-1]["LivelloID"] = 0;
}
MF
Mauro Fiore
November 3, 2004 02:13 PM UTC
CLay,
it is been my inobservance, excuse me (if you want can delete that column).
I should like know, however, how to insert, to delete, to reject and to save data using the botton object.
Thanks again,
Mauro
MF
Mauro Fiore
November 5, 2004 05:28 AM UTC
Clay,
thanks for all your help, I believed should be more simple to use Essential Grid object but I have a lot of problems yet and I haven''t time to spend now to understand all the behaviors of the object (straightforwardly there is too little documentation).
Thanks again and I hope to be able to use Essential Grid in my projects in near future.
Hi,
Mauro