Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to add a new row to a grid by typing in a New Item Row in a similar manner used in a standard DataGridView

$
0
0

If you want to exactly emulate the standard DataGridView behavior, i.e. the new item row should appear immediately after typing in a column's cell, you need to introduce this functionality manually.

For this, set the GridView.OptionsView.NewItemRowPosition property to Bottom.
Then, handle the RepositoryItem.EditValueChanged event:
      close the active editor and post changes by calling the GridView.CloseEditor method,
      then call the GridView.UpdateCurrentRow method to save a new row to the underlying data source.
To show the cell's in-place editor again, call the GridView.ShowEditor method.

This example illustrates how to accomplish this task.

Question Comments

Added By: Dave Conrad at: 9/4/2015 11:16:53 AM    

Attempted to use this code...

Testing the code, i enter a value into one of the cells, as I press my first key, at the following line... (I'm using the vb version)

GridView.UpdateCurrentRow

I get a popup error...

The column 'pkid' does not allow nulls.  Do you want to correct the value (Yes or no) - if I click yes, it just keeps popping up the message infinitely.

I have tried setting the pkid value before UpdateCurrentRow method, with a line of code as such...

ApTxDistAdvBandedGridView.SetRowCellValue(ApTxDistAdvBandedGridView.FocusedRowHandle, "Pkid",fnMyPkidGenerator)

This however does not help, the error still occurs.  Pkid is a SQL Key from Microsoft SQL Server and does not allow nulls.  I am assinging keys programatically in code.

Also, the error popup does not seem to be trappable.  Maybe a function of the control itself ?

Hope you can help!

Screen capture here --> http://screencast.com/t/rk5qqAImJWY


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>