Search code examples
delphidbgrid

Bound DBGrid to Custom Component


I make one component in Delphi 10 Seattle. My component is one panel contains one TDBGrid (from TCustomDBGrid) and one TEdit Controls. When i put my component to form, everything is fine, if i don't change Grid Columns. but when i changed bounded DBGrid Columns, an error happens on run time with message: "Error reading TColumn.MyGrid.Expanded: Property MyGrid.Expanded dos not exist. ..." For found error, i opened form as text and see this codes:

MyGrid.Columns = <
  item
    MyGrid.Expanded = False
    MyGrid.FieldName = 'Sid'
    MyGrid.Visible = True
  end
  item
    MyGrid.Expanded = False
    MyGrid.FieldName = 'UserName'
    MyGrid.Visible = True
  end>
FilterDataSource = DataSource1

Thus, my component not worked correctly.


Solution

  • I wrote my own component embedding a TDBGrid in a TPanel and a project to test it. I got the same error as you when I tried to reload my project when the grid included persisted TColumns.

    So, I posted my own q here

    How to correctly stream a TCollection property of a subcomponent, e.g. the Columns property of an embedded TDBGrid

    and got an answer from Delphi MVP Uwe Raabe basically saying that the cause is a problem in the VCL streaming code of TDBGridColumns and suggesting that I file a problem report ot EMBA's Quality Portal. SO I don't think there is much that can be done about the problem until EMBA fix it.