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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Intercepting in-place editing in a GDBG

Thread ID:





32901 Aug 9,2005 10:17 PM UTC Aug 29,2005 07:01 PM UTC WinForms 14
Tags: GridControl
Chuck Hill
Asked On August 9, 2005 10:17 PM UTC

Hi, I am trying to intercept writing to a cell after returning from in-place editing within in a GridDataBoundGrid. The reason is that I cannot edit a cell bound to a DataSet column containing an expression. No matter what I do, the cell is treated as read-only. I want to intercept the call so I can convert the value and put it into the proper cell in a hidden DataSet column. Thanks, Chuck

Administrator [Syncfusion]
Replied On August 9, 2005 10:47 PM UTC

Try subscribing to the grid.Model.SaveCellInfo event. There, you can test e.RowIndex and e.ColIndex to check what cell you are working with, and you can get the value from e.Style.CellValue so you can do something else with it. You should also set e.handled = true so the grid does not try to save the value itself.

Chuck Hill
Replied On August 12, 2005 06:27 PM UTC

Your solution works great for DataSet columns that contain writable data but does not work for underlying DataSet columns that contain only an expression. The GDBG cell enters edit mode, the text in the cell is selectable, but the characters in the cell refuse to change. I want to edit these columns, intercept the values and write the results to the hidden columns that the underlying DataSet column expressions refer to. Thanks, Chuck

Administrator [Syncfusion]
Replied On August 12, 2005 11:43 PM UTC

To avoid the expression columns being editable, try handling the CurrentCellStartEditing event. If grid.CurrentCell.ColIndex points to one of your expression columns in your event handler, then set e.Cancel = true.

Chuck Hill
Replied On August 16, 2005 12:24 AM UTC

Actually, I _want_ to edit the cell and intercept the results.

Administrator [Syncfusion]
Replied On August 16, 2005 12:38 AM UTC

You can try the CurrentCellValidating event. To get the new value of the cell, you can use grid.CurrentCell.Renderer.ControlText.

Chuck Hill
Replied On August 16, 2005 06:10 PM UTC

I tried that and it doesn''t work. I need to be able to modify the characters in the cell before any of those events are fired.

Administrator [Syncfusion]
Replied On August 16, 2005 06:45 PM UTC

If you want to specify the text that appears in the cell when the cell starts editing, then handle the CurrentCellInitializeControlText event. private void gridControl1_CurrentCellInitializeControlText(object sender, GridCurrentCellInitializeControlTextEventArgs e) { e.ControlText = "ABC"; }

Chuck Hill
Replied On August 17, 2005 04:39 PM UTC

Unfortunately, I am not making myself very clear. While the application is running the GDBG column cells enter edit mode, the cell contents are selectable for ctrl-c copy operations, but the characters in the cell cannot be changed. The keystrokes are ignored. I want the grid cell to be truely editable where I can insert/remove characters within the cell. Because the underlying Table column does not contain data but a computed expression from another Table column, I want to intercept the modified grid cell contents and reverse-compute the value and put it into the source Table column. The readonly flag is NOT set. gridColumn.StyleInfo.CellType = "TextBox"; The underlying DataTable column does not contain data but contains an expression. As an example dv = this.myGrid.Binder.DataSource as DataView; Where dv.Table.Columns["area_squm"].Expression == "ISNULL(area,0) * 0.000001". The hidden Table column "area" contains the value in sq.nm but the value is presented to the user as sq.um Please let me know if you are still unclear about what is occuring and what I want to do. Thanks

Administrator [Syncfusion]
Replied On August 17, 2005 06:34 PM UTC

Here is a sample. No matter what you type into Col1, it will store something different (that you can specify) in the DataTable. It does this by handling the grid.Model.DataProviderSaveCellInfo event. http://www.syncfusion.com/Support/user/uploads/GDBC_Sample_a003f3f.zip

Chuck Hill
Replied On August 17, 2005 08:28 PM UTC

Here''s your sample slightly modified so that it simulates my issue. Form1_6722.zip

Administrator [Syncfusion]
Replied On August 17, 2005 09:18 PM UTC

>>this.gridDataBoundGrid1.CurrentCell.Renderer.ControlValue You cannot use this is SaveCellInfo. SaveCellInfo can be hit for many reasons, and you cannot assume that Renderer.ControlValue will have any particular value. Suppose you write the expression as: this.dt.Rows[e.RowIndex - 1]["Col2"] = XXXXX; The question is exactly where do you want XXXXXX to come from? And what cell do you type in to decide that you can to set Col2 to be some value?

Chuck Hill
Replied On August 18, 2005 05:18 PM UTC

OK. Not only do I want to know how to modify the text within a cell in "Col3", but I want to know how to retrieve the value so I can transform and set it to the cell in "Col2".

Administrator [Syncfusion]
Replied On August 18, 2005 11:00 PM UTC

I think I understand what you want now. Here is a modified sample. If uses an unbound column to offer the flexibility of editing the computed column. http://www.syncfusion.com/Support/user/uploads/GDBC_Sample_2668fdde.zip

Chuck Hill
Replied On August 29, 2005 07:01 PM UTC

Thanks! It works in my code. --Chuck


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