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.

Inserting and Deleting a Row With the Help of Context Menu

Thread ID:

Created:

Updated:

Platform:

Replies:

16001 Jul 2,2004 03:30 AM Aug 20,2004 05:34 AM Windows Forms 8
loading
Tags: GridControl
arvind
Asked On July 2, 2004 03:30 AM

Hai, I am using ur product and I want a piece of code where I can insert and delete a row with the help of the Context Menu Thanks and Regards, Hsee

Administrator [Syncfusion]
Replied On July 2, 2004 04:23 AM

What rid control are you using? GridControl, GridDataBoundGrid or GridGroupingControl? There are different technique requred for each type of grid as they use different data sources.

arvind
Replied On July 2, 2004 04:40 AM

I am using GridDataBoundGrid.Could u please update on yhe information provided. >What rid control are you using? GridControl, GridDataBoundGrid or GridGroupingControl? > >There are different technique requred for each type of grid as they use different data sources.

Administrator [Syncfusion]
Replied On July 2, 2004 08:00 AM

Here is a sample. DeleteContext_5448.zip

arvind
Replied On July 3, 2004 02:21 AM

After inserting two rows ,when i try 2 add some values to the cell it throws an error and the newly added values move to the last row.Could you help me with this problem. Thanks, Hsee

Administrator [Syncfusion]
Replied On July 3, 2004 08:04 AM

Adding a RowLeave event handler and making a slight change in the menuhandler made the sample work ok for me.
private void menuItem2_Click(object sender, System.EventArgs e)
{
	//insert
	if(this.mouseDownRow > -1 && this.mouseDownCol > -1)
	{
		int position = this.gridDataBoundGrid1.Binder.RowIndexToPosition(mouseDownRow);
		this.gridDataBoundGrid1.BeginUpdate();
		DataRow dr = dt.NewRow();
		this.dt.Rows.InsertAt(dr, position);
		this.dt.AcceptChanges(); 
		this.gridDataBoundGrid1.EndUpdate();
	}
}

private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	dt.AcceptChanges();
}

arvind
Replied On July 4, 2004 10:05 PM

Hai the peice of code works only when u have more than one row and while u r updating the first row the attached werror will be dispalyed. Could you find any solutions if possible for this untitled_1939.zip

Administrator [Syncfusion]
Replied On July 5, 2004 02:17 AM

Try this code in Row_Leave.
private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
{
	if(this.dt.Rows.Count > 0)
		dt.AcceptChanges();
}

arvind
Replied On August 20, 2004 05:34 AM

If I have the dataTable.AcceptChanges() in the row leave event ,then all the rows in the dataTable will have row State as Unchanged ,this is making my saving difficult. >Try this code in Row_Leave. >
>private void gridDataBoundGrid1_RowLeave(object sender, GridRowEventArgs e)
>{
>	if(this.dt.Rows.Count > 0)
>		dt.AcceptChanges();
>}
>

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.

;