How to sync a StringGrid with the Dataset ?

If I select a row on a StringGrid and read the dataset record (as I would on a dbgrid) the dataset cursor is set to the first record. 
Is there a way to get the StringGrid to sync with the Dataset ?

Similarly when updating the dataset with a select query, the StringGrid does not sync and reflect the new data in the dataset (unless I set BindSourceDb.dataset := nil and then BindSourceDb.dataset = dataset after the query re-opens, which does not seem the correct approach). I am looking for a way to sync the StringGrid with the current dataset and selected record if a row if selected

I have a StringGrid with '*' Binding to BindSourceDb '*' and A BindPosition Link as detailed below. The BindSourceDB is linked at a TFDQuery dataset. I am using XE5.

object LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource
  Category = 'Quick Bindings'
  DataSource = BindSourceDB1
  GridControl = dgCustomer
  AutoBufferCount = False
  Columns = <
    item
      MemberName = 'ID'
      Width = 40
    end
    item
      MemberName = 'NAME'
      Header = 'Name'
      Width = 300
    end>
end

object BindPosition1: TBindPosition
  Category = 'Links'
  ControlComponent = dgCustomer
  SourceComponent = BindSourceDB1
  PosSourceExpressions = <
    item
      ControlExpression = 'Selected+1'
      SourceExpression = 'RecNo'
    end>
  PosControlExpressions = <
    item
      ControlExpression = 'Selected'
      SourceExpression = 'RecNo -1'
    end>
  PosClearExpressions = <>
end
0
jon
8/6/2015 11:05:45 AM
embarcadero.delphi.firemonkey 4901 articles. 2 followers. Follow

0 Replies
365 Views

Similar Articles

[PageSpeed] 34

Reply:

Web resources about - How to sync a StringGrid with the Dataset ? - embarcadero.delphi.firemonkey

Resources last updated: 12/15/2015 7:53:15 PM