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.

Setting CellValue in Databound grid adds extra row

Thread ID:

Created:

Updated:

Platform:

Replies:

7848 Oct 10,2003 02:08 PM Oct 20,2003 04:20 AM Windows Forms 12
loading
Tags: GridControl
Rajeev Kulam
Asked On October 10, 2003 02:08 PM

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 1.6.1.0 Thanks in advance

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

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 12:49 PM

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 02:17 PM

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 04:16 AM

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 04:52 AM

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

Dave Hermans
Replied On October 17, 2003 05:15 AM

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 05:30 AM

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 05:39 AM

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

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

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

Dave Hermans
Replied On October 20, 2003 03:09 AM

Clay, we are using Essential suite 1.5.2.0. 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 04:00 AM

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(cc.IsEditing)
		{
			if(tb.SelectionLength == 0)
				tb.SelectionLength = 1;
		}
		else
			tb.SelectAll();
		tb.SelectedText = "";
	}
}

Dave Hermans
Replied On October 20, 2003 04:20 AM

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

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.

;