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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Working with "insert" row in GDBG.

Thread ID:

Created:

Updated:

Platform:

Replies:

20985 Oct 29,2004 01:20 PM UTC Oct 31,2004 03:58 PM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On October 29, 2004 01:20 PM UTC

I have a GDBG in which EnableAddNew is enabled. The GDBG is bound to a DataSet that is populated by a DataAdaptor which is filled with the contents of a user-specified table (or view) from a database. I wanted to prevent users from editing those columns which are part of either the primary key for the underlying table or one of the unique indexes for the table or a database view. The following code is used to accomplish this (note that the _dbCmdBuilder class is a homegrown replacement for the CLRs CommandBuilder that corrects some limitations of that class): for (int n = 1; n <= grid.Model.ColCount; n++ ) { if ( _dbCmdBuilder.IsColumnReserved(n - 1) ) { grid[-1,n].CellType = "static"; grid[-1,n].ReadOnly = true; } } This works fine except that it also prevents users from editing those same columns when inserting a new row (in the insertion row at the bottom). How can I keep all the cells in that bottom insertion row editable? Thanks, Andy

Administrator [Syncfusion]
Replied On October 29, 2004 02:11 PM UTC

One way to do this is to handle the grid.Model.QueryCellInfo event, and if e.ColIndex > 0 && e.RowIndex == grid.Model.RowCount, then set e.Style.Enabled = true and e.Style.CellType = "TextBox".

Administrator [Syncfusion]
Replied On October 29, 2004 03:06 PM UTC

Clay, That works, almost. It does allow me to edit the first "key" column. But as soon as you start editing in a cell in the insert row, a new insert row is created which makes the row I''m in revert to non-editable for key columns. This can create a problem if I have a row with multiple key-column cells that need values because after leaving the first key-column, the other cells have reverted to non-editable. I''m considering having a seperate one-row, non-bound grid control above (or below) the GDBG in which users can add new rows... but that seems a bit drastic. Andy >One way to do this is to handle the grid.Model.QueryCellInfo event, and if e.ColIndex > 0 && e.RowIndex == grid.Model.RowCount, then set e.Style.Enabled = true and e.Style.CellType = "TextBox".

Administrator [Syncfusion]
Replied On October 29, 2004 03:12 PM UTC

I had a thought. Somewhere, probably in the ADO.NET stuff, there must be a flag marking new rows as needing to be inserted (via the INSERT statement set-up in the data adapter. If I can figure out which rows in the grid match those rows in the datatable that are "insertable", then I can leave those editable until such time as the dataset is updated via the data-adaptor. I don''t know the CLR or ADO.NET or the grid control''s binding mechanism well enough yet to know where to look for such a flag. Any thoughts? >Clay, > >That works, almost. It does allow me to edit the first "key" column. But as soon as you start editing in a cell in the insert row, a new insert row is created which makes the row I''m in revert to non-editable for key columns. > >This can create a problem if I have a row with multiple key-column cells that need values because after leaving the first key-column, the other cells have reverted to non-editable. > >I''m considering having a seperate one-row, non-bound grid control above (or below) the GDBG in which users can add new rows... but that seems a bit drastic. > >Andy > >>One way to do this is to handle the grid.Model.QueryCellInfo event, and if e.ColIndex > 0 && e.RowIndex == grid.Model.RowCount, then set e.Style.Enabled = true and e.Style.CellType = "TextBox".

Administrator [Syncfusion]
Replied On October 29, 2004 03:21 PM UTC

Try checking if(e.ColIndex > 0 && (e.RowIndex == grid.Model.RowCount || grid.Binder.IsInAddNew)) { // }

Mauro Fiore
Replied On October 31, 2004 02:47 PM UTC

Apologize me but where do I find the GQueryCellInfo event in GridDataBoundGrid object? thanks all, Mauro.

Administrator [Syncfusion]
Replied On October 31, 2004 03:58 PM UTC

It is in the Model member, grid.Model.QueryCellInfo. this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);

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

;