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.

Error, Urgent Please do help!

Thread ID:

Created:

Updated:

Platform:

Replies:

37176 Nov 16,2005 08:36 PM Nov 18,2005 02:22 PM Windows Forms 15
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 16, 2005 08:36 PM

Hi, I have griddataboundgrid attached to collection to business entity. I have Grid.eabledaddnew=true; Now when I retrieve the data from database I get 3 rows and collection have 3 rows. But my grid display one more empty row at the bottom, which is good. But as son as I type something in any of cell in 4th row I get the error message, probably because this row (4th) is not there in collection. Please find the attached file for error message. Please do help! Rick

error4.zip

Administrator [Syncfusion]
Replied On November 16, 2005 09:21 PM

Does your collection implement IBindingList and does it have IBindingList.AddNew implemented? If not, then you will have to turn off grid.EnableAddNew or you will have to write code to handle adding the row to your collection when your user enters the AddNew row. You can subscribe to the grid.RowEnter event and check if you are on the last row to decide whether you need to add a new item to your collection.
private void gridDataBoundGrid1_RowEnter(object sender, GridRowEventArgs e)
{
	if(this.gridDataBoundGrid1.Model.RowCount == e.RowIndex)
		Console.WriteLine("need to add new item");
}

Administrator [Syncfusion]
Replied On November 17, 2005 03:22 AM

Or you can transform your collection to a DataTable and bind that to the grid. I wrote my own generic transformation from collection of business entities to a DataTable and back using reflection. When using a DataTable you can also do column sort in the grid. Rune

Administrator [Syncfusion]
Replied On November 17, 2005 01:02 PM

Sorry my mistake, It is working now. New rows are working fine. I have another problem with eidt. Whenever I edit something on old rows my business entity is not updated with new values. Please suggest something. Thanks,

Administrator [Syncfusion]
Replied On November 17, 2005 01:15 PM

Exactly what is your business entity? What interfaces does it implement? If it is a IList of strongly typed objects with public properties, then normally, the item will be updated when you leave the grid row. If you are binding to some arbitrary array, then you might have to handle grid.Model.SaveCellInfo. In that event, based on e.RowIndex and e.ColIndex, you would store e.Style.CellValue into your datasource.

Administrator [Syncfusion]
Replied On November 17, 2005 02:34 PM

Clay, I have some more info for you. My object implementing the IBindList collection properly and my collection implement the IEditableObject. It looks like it works only if I leave the row/grid but not while doing a tab out from a cell. I need to force the the grid to set the values right away so that my business object can calculate other cell values. regrads,

Administrator [Syncfusion]
Replied On November 17, 2005 02:41 PM

Clay, I tried the following code and it looks like that grid is working. Please confirm that this is the right way. private void gdbgSalary_CurrentCellAcceptedChanges(object sender, System.ComponentModel.CancelEventArgs e) { this.gdbgSalary.CurrentCell.EndEdit(); this.gdbgSalary.Binder.EndEdit(); }

Administrator [Syncfusion]
Replied On November 17, 2005 02:44 PM

Two more Issues! #1 Delete key doesn''t work withing the cell, in order to delete few letters? #2 How can i stop user to entering the invalid values(string in int and int in string)? Thanks,

Administrator [Syncfusion]
Replied On November 17, 2005 03:02 PM

The delete key works OK when you select some text in cell in this sample using version 3.3. http://www.syncfusion.com/Support/user/uploads/GDBG_DeleteKey_4015581b.zip What are you doing differently? Do you have any menu or toolbar items that might be using the Delete as a hotkey? If so, then that will eat thos keystroke so the grid does not get it. Is the cell set to be readonly? That would prevent the delete from working.

Administrator [Syncfusion]
Replied On November 17, 2005 03:11 PM

Clay, Please confirm the binding solution i sthe right way? Please confirm that this is the right way. private void gdbgSalary_CurrentCellAcceptedChanges(object sender, System.ComponentModel.CancelEventArgs e) { this.gdbgSalary.CurrentCell.EndEdit(); this.gdbgSalary.Binder.EndEdit(); }

Administrator [Syncfusion]
Replied On November 17, 2005 03:25 PM

The code you added in CurrentCellAcceptedChanges will force the grid to raise the IBindingList.ListChanged event on the datasource. The default behavior of the grid is to only raise this event when you leave the row. If you want it raised with every change even if you do not leave the row, then your code is OK.

Administrator [Syncfusion]
Replied On November 17, 2005 04:41 PM

Thanks clay, I am not using any hot key on my form. i am attached entire code for my grid from form.. Please see if you could find something. thanks,

gridcode0.zip

Administrator [Syncfusion]
Replied On November 17, 2005 05:20 PM

I did not see anything. You are talking about a TextBox cell and not a ComboBox cell. For your combobox cells, you have them set to Exclusive which means you can only enter values fdrom the list. This might affect the delete key behavior. If you can upload a sample project showing the problem, we can try to debug it.

Administrator [Syncfusion]
Replied On November 18, 2005 03:47 AM

I guess i might know the problem. When I am pressing the ''Del'' key the current row is still selected. Grid #1 where ‘0’ column is not hidden, I can see the arrow for row selection. As soon as I press ''del'' key the row gets deleted from the grid. Grid # 2 As soon as I press ''del'' key, basically nothing happens, I mean it nothing happens even row doesn’t get deleted (because IbindList.AllowRemove =false). Does this give you any idea, why ‘Del’ ke is nt working properly?

Administrator [Syncfusion]
Replied On November 18, 2005 05:29 AM

Are you using version 3.3? What version of our libraries are you using? The delete key not deleting selected text, but deleting the whole row instead was a behavior in our earlier versions, but should work in 3.3. Here is some work-around code that may handle this problem for you - but you may have to set AllowRemove true for th eevent to be hit. (You can always set e.Cancel in the event to prevent all deletecions instead of relying on this property.) private void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e) { if(this.grid.CurrentCell.IsEditing) { e.Cancel = true; GridTextBoxControl tb = this.grid.CurrentCell.Renderer.Control as GridTextBoxControl; if(tb.SelectionLength == 0) tb.SelectionLength = 1; tb.SelectedText = ""; } }

Administrator [Syncfusion]
Replied On November 18, 2005 02:22 PM

Thanks clay, I am using 3.0.1.1. no plan for upgrade. I am still having the following problem, even though i set the allowremove=true. it doesn''t do anything when i press ''Del'' key. Grid # 2 As soon as I press ''''del'''' key, basically nothing happens, I mean it nothing happens even row doesn’t get deleted. Thanks,

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.

;