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.
Syncfusion Feedback

Grid Attempts to Store Values in Read-Only Columns

Thread ID:

Created:

Updated:

Platform:

Replies:

20974 Oct 29,2004 07:47 AM UTC Nov 2,2004 11:46 AM UTC Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On October 29, 2004 07:47 AM UTC

Hi, I''m using the GridDataBoundGrid (2.1.0.9). It tries to write values back to the data source even when the column is marked as read-only. This causes a cast exception as the values have been turned into strings by custom cell renderers and the original data source stores doubles. How do I prevent the grid from accessing settor properties on the read-only columns? Thanks, Ben.

Administrator [Syncfusion]
Replied On October 29, 2004 08:15 AM UTC

I am not sure why this is happening??? If the cell is ReadOnly, the grid should not allow the cell to change, and thus, should not have a reason to try to save it. But here is something to try. Handle the grid.Model.SaveCellInfo event. In your handler, if e.ColIndex points to the ReadOnly column, and e.RowIndex > 0, then set e.Handled = true to see if this prevents the exception. If this does not handle the problem, if you will post a little sample showing the problem, maybe we can suggest something else.

Administrator [Syncfusion]
Replied On November 2, 2004 10:32 AM UTC

Clay, Thanks for your reply. I tried adding an event handler to grid.Model.SaveCellInfo but it was never called when the column was resized. My custom renderers override GetFormattedText(), they were taking a value for a long field and formatting it as a text string. Rather than just returning the formatted string I was also setting style.Text which was attempting to set the value in the datastore and causing the problem. The custom cell renderers are behaving the way I want them to. Except the currently selected cell ignores the cell justification so all my right justified text shoots to the left. Is there any way to prevent this? Another problem with using GetFormattedText() is when automatically resizing the column width the grid only sees the unformatted values which happen to be slightly narrower e.g. 123456 rather than ($123,456). Is it possible to add on a margin of error? Thanks, Ben.

Administrator [Syncfusion]
Replied On November 2, 2004 11:46 AM UTC

SaveCellInfo is only called when a cell value changes. Changing the size of a column should not save anything to your datasource, and this woul dbe why SaveCellInfo is not hit. Your renderer.Draw method override is responsible for drawing any text properly aligned. Are you overridng this method. If so, you will have to handle the aligment appropriately. If not, I am not sure why the alignment is being ignored. If you can post a little sample project showing the problem, maybe we can spot something here. And your model.CalculatePreferredCellSize method override is responsible for providing the optimal cell size when ResizeToFit is called. So, if you are not overridng CalculatePreferredCellSize, then you should try that to provide teh size you want the cell to be. A cheap implementation might be to call the base class, and then tweak the value for the extra space before returning it.

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.

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

;