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

Intercepting in-place editing in a GDBG

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

14 Replies

AD Administrator Syncfusion Team 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.

CH Chuck Hill 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

AD Administrator Syncfusion Team 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.

CH Chuck Hill August 16, 2005 12:24 AM UTC

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

AD Administrator Syncfusion Team 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.

CH Chuck Hill 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.

AD Administrator Syncfusion Team 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"; }

CH Chuck Hill 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

AD Administrator Syncfusion Team 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

CH Chuck Hill August 17, 2005 08:28 PM UTC

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

AD Administrator Syncfusion Team 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?

CH Chuck Hill 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".

AD Administrator Syncfusion Team 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

CH Chuck Hill August 29, 2005 07:01 PM UTC

Thanks! It works in my code. --Chuck

Live Chat Icon For mobile
Up arrow icon