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.

Working with "insert" row in GDBG.

Thread ID:

Created:

Updated:

Platform:

Replies:

20985 Oct 29,2004 09:20 AM Oct 31,2004 10:58 AM Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On October 29, 2004 09:20 AM

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 10:11 AM

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 11:06 AM

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 11:12 AM

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 11:21 AM

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

Mauro Fiore
Replied On October 31, 2004 09:47 AM

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

Administrator [Syncfusion]
Replied On October 31, 2004 10:58 AM

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.

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.

;