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

Selective column edit enabling in a GDBG

Hi, I have some grids where I want to enable editing on a few columns. The easiest approach seems to be make the grid readonly and selectively enable the columns. In going through the docs I see that styles are evaluated from a higher level (grid) to a lower level (cell). Does this also apply when dealing with readonly property? Also, what is the difference between readonly and enableEdit? Also, also, the values in some of the columns are dependent upon values in the editable ones. It looks like readonly also prevents dynamic updates of cells. If I set ignoreReadonly on on columns requiring dynamic updates, will that continue to prevent user updates to the column? Thanks, Doug Lind

7 Replies

AD Administrator Syncfusion Team October 22, 2003 03:39 PM UTC

To make the whole grid readonly except for a few columns, first for each column that you want to be able to edit, set gridBoundColumn.StyleInfo.ReadOnly = false; After that (and after you have set any other style properties you want to set), set grid.TableStyle.ReadOnly = true;. This will effectively set everything readonly except the columns explicitly set to ReadOnly = false. grid.EnableEdit = false is another way to make the whole grid un-editable. It mimics the properties of the standard DataView class with its AllowEdit and AllowAddNew, etc. If you set IgnoreReadOnly to true, make your programatic changes, and then immediately set it back to false, then your user should not be able to make changes to your readonly cells.

DL Doug Lind October 22, 2003 06:27 PM UTC

Thanks for the help, it works well. Now, what event should I be using in a GDBG to capture when a user changes cell data? I looked at CellChanged but it seems to be specific for the grid control, and I don't see anything similar for a GDBG. BTW Does changing a cell value auto-magically update the datasource by default? If not, can you point me to an appropriate example? Thanks again Doug

AD Administrator Syncfusion Team October 22, 2003 09:25 PM UTC

The CurrentCellChanged event is available in a GridDataBoundGrid. Changes to a single row are cached until the user leaves the row, and at that point is when the changes are saved to the datasource. You can flush any pending changes with code like grid.Binder.EndEdit(). (If you are uses ADO.NET and a dataadapter, then you will also have to call dataadapter.Update to flush the changes cached by ADO.NET back to the actual datasource.)

DL Doug Lind October 23, 2003 01:24 PM UTC

Great Clay, Now I need to retrieve the cached value so it can be used to update another column. I don't want to wait for a rowchange event plus I'd lose which cell was updated. Maybe you know of a better way. Basically I just want to update one column from another when the source column is changed. Not after they leave the row. BTW Do I need to update both the cell value and text, or is the value alone sufficient?

AD Administrator Syncfusion Team October 23, 2003 02:04 PM UTC

I would do this in the CurrentCellAccepted event. private void gridDataBoundGrid1_CurrentCellAcceptedChanges(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; Console.WriteLine(this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].Text); } CellValue alone is sufficient to set a cell's value.

DL Doug Lind October 23, 2003 05:20 PM UTC

Hey Clay, Sorry to keep bugging you but I'm overwhelmed by all the events you have. What I need is to trigger a display update when a GDBG row selection changes. For my purposes, this means when the arrow in the far left column changes position. I don't want the whole range, just the row with the arrow. I see that GDBG.model has SelectionChanged event but can't get a handler to hookup with it. Even if it did, how would I determine which row has the arrow? Thanks, Doug Lind

AD Administrator Syncfusion Team October 23, 2003 05:46 PM UTC

There are RowLeave and RowEnter events you might be able to use. There is also a CurrentCellMoved event. In that event, you can check grid.CurrentCell.MoveToRowIndex and grid.CurrentCell.MoveFromRowIndex to see if you have changed rows, and there you know both the new and old row.

Live Chat Icon For mobile
Up arrow icon