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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting CellValue in Databound grid adds extra row

Thread ID:





7848 Oct 10,2003 06:08 PM UTC Oct 20,2003 08:20 AM UTC WinForms 12
Tags: GridControl
Rajeev Kulam
Asked On October 10, 2003 06:08 PM UTC

Setting cell value programmatically to the last cell in a databound grid adds an extra row to the grid as well as sets the same value to column in the next row. For eg. this.gridDataBoundGrid1[this.gridDataBoundGrid1.Model.RowCount-1,1].CellValue = "1"; will add an extra row to the grid as well as sets the [rowcount,1] cellvalue to "1". Is there any I could change a cell value without adding new rows? I am using the Syncfusion Grid Thanks in advance

Administrator [Syncfusion]
Replied On October 10, 2003 11:04 PM UTC

If you want to change values in the AddNew row then you should first call Binder.AddNew() and after changing the cell value call Binder.EndEdit(). If you do not want the AddNew behavior supported by the grid then set AllowAddNew = false. Let me know if you need more info. Stefan

Rajeev Kulam
Replied On October 13, 2003 04:49 PM UTC

This happens on an existing row (always the last but one row). Databound grid is adding a new row If I set cell value to the last row existing in the databound grid (not the add new row).

Administrator [Syncfusion]
Replied On October 13, 2003 06:17 PM UTC

Sorry I misunderstood first. I see the problem and we'll get that fixed in the grid source code. A workaround would be in the meantime to set AllowAddNew = false before setting the value and resetting AllowAddNew = true after you changed the value. Stefan

Dave Hermans
Replied On October 17, 2003 08:16 AM UTC

I have tried this workaround, but after resetting the allownew property the empty line is disapeared, making it impossible to add new records. if you manualy edit another cell, it does add a new line.

Administrator [Syncfusion]
Replied On October 17, 2003 08:52 AM UTC

Attached is a project wher eteh work around seems to do ok. What are you doing differently?

Dave Hermans
Replied On October 17, 2003 09:15 AM UTC

If i'm not mistaking the project contained 2 ways to clear the cell. I tried both. the first, with the clearcells command, ran ok without errors, but it didn't clear the cell. the second, with the enableaddnew, ran without errors and cleared the cell contents, but the extra empty line was gone. it reapeared only when manualy editing another cell.

Administrator [Syncfusion]
Replied On October 17, 2003 09:30 AM UTC

I sent this particular project to test changing EnableAddNew on the fly to avoid the problem you described in your post. Did not pressing the button change the on the last line of good data in the grid? If you want to test the clear with the delete key in this sample, try setting the grid ListBoxSelectionMode to One. Otherwise, delete will be handled by the actively editing cell (and will not delete either the row or the whole cell contents, but instead will delete the next character in the string if there is one).

Administrator [Syncfusion]
Replied On October 17, 2003 09:39 AM UTC

Looking at the code, it does have ListSelectionMode set. Sorry. What version of our library are you using? I tried this with (pressing the delete key, and it seemed to work for me with that version.

Administrator [Syncfusion]
Replied On October 17, 2003 01:23 PM UTC

The original problem posted at the beginning of this thread has been fixed in version, a private build. You can get that release by submitting a support incident and requesting it.

Dave Hermans
Replied On October 20, 2003 07:09 AM UTC

Clay, we are using Essential suite What i want the delte key to do is the same as it does in word for example delete the caracter. I have a seperate button to delete the whole line. I've tried setting the selectionmode to none, but it still deleted the line. Greetings, Dave

Administrator [Syncfusion]
Replied On October 20, 2003 08:00 AM UTC

You might be able to do this from with the RowDeleting event.
private void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl; 
	if(tb != null)
		e.Cancel = true;
			if(tb.SelectionLength == 0)
				tb.SelectionLength = 1;
		tb.SelectedText = "";

Dave Hermans
Replied On October 20, 2003 08:20 AM UTC

Thanks Clay, this is what i need. Greetings, Dave


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon