We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding rows in a GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

21033 Nov 1,2004 12:40 AM Nov 5,2004 12:28 AM Windows Forms 14
loading
Tags: GridControl
Mauro Fiore
Asked On November 1, 2004 12:40 AM

Hi all, it''s the first time that I use the Essential Grid and I''m trying to insert a new row in a GDBG. I was able to view the DataSet Table and to view only the columns that I wished, but when I want to insert a new row (I move mouse to the end of the GDBG and I place the mouse to the * row) immediately after that I insert a value in any cell all the rows in the GDBG disappear and I don''t know what to do. How can I solve the problem ? Thanks all, Mauro SnippetCode_7238.zip

Mauro Fiore
Replied On November 1, 2004 12:54 AM

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

Administrator [Syncfusion]
Replied On November 1, 2004 01:27 AM

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.

Mauro Fiore
Replied On November 1, 2004 11:38 PM

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

Administrator [Syncfusion]
Replied On November 2, 2004 01:14 AM

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

Mauro Fiore
Replied On November 2, 2004 02:12 AM

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.

Mauro Fiore
Replied On November 2, 2004 02:23 AM

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

Administrator [Syncfusion]
Replied On November 2, 2004 02:38 AM

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();
	}
}

Mauro Fiore
Replied On November 2, 2004 03:37 AM

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

Administrator [Syncfusion]
Replied On November 2, 2004 03:57 AM

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();
	}
}

Mauro Fiore
Replied On November 3, 2004 01:58 AM

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

Administrator [Syncfusion]
Replied On November 3, 2004 04:51 AM

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;
 
}

Mauro Fiore
Replied On November 3, 2004 09:13 AM

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

Administrator [Syncfusion]
Replied On November 3, 2004 11:41 AM

Here is you sample back with some changes. WindowsApplication1_81_5722.zip

Mauro Fiore
Replied On November 5, 2004 12:28 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;