StrataFrame Forum

Using a .NET DataGridView with SF

http://forum.strataframe.net/Topic23147.aspx

By Edhy Rijo - 5/15/2009

I am using a DataGridView with a BBS generated with "SF Custom Business Binding Source", I just selected "Create a Custom Business Binding Source". I dropped an instance of the BO in the form and in order for the grid to show some data I had to do the following:

Me.TransactionItemsStockBBS1.BusinessObject = Me.BizTransactionItemsStock1




I am using a datagridview because the end user can modify some values in any record in the grid, I need to do the following:

1- Validate the change made by the user in the column. What would be the proper event to do the validation?

2- In the validation, I need to do some calculations with the data in the grid, how to know in which record the grid is positioned to do my calculations, also this calculations involve scanning through the records, I am using a FOR..ENFOR bo.GetEnumerable(), but does know if the record pointer will be moved in the form's BO instance?

3- Will the record pointed be in synch in the form's BO while navigating the grid?
By Trent L. Taylor - 5/18/2009

  1. If you are using a DataGridView, the BO rules will show on the broken rules columns when the save is called just as though it would for a textbox, etc.  The ErrorProvider will show within the grid column.  So it just becomes a matter of whether you want to prevent navigation if there are broken rules.  If so, then you can use the RowValidating event of the DataGridView and set the e.Cancel = True if you do not want to allow navigation until the row corrected.
  2. If you will do a For Each...bo.GetEnumerable(), the row position will be automatically saved off and restored and you will not have to do anything to retain your current position.
  3. If you are referencing the same instance of the BO on the form and the grid, then the CurrentRowIndex will be the same.
By Edhy Rijo - 5/18/2009

Thanks for the points, will check them out.