Skip to content

Commit

Permalink
Prevent access violation when trying to access a non-existent grid co…
Browse files Browse the repository at this point in the history
…lumn
  • Loading branch information
davidberneda committed Oct 27, 2023
1 parent 1d00f5c commit 3ed2dff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
object SampleData: TSampleData
OldCreateOrder = False
Height = 337
Width = 267
object Sqlite_demoConnection: TFDConnection
Params.Strings = (
'Database=D:\apps\Embarcadero\Studio\19.0\Samples\Data\FDDemo.sdb'
'ConnectionDef=SQLite_Demo')
Connected = True
LoginPrompt = False
Left = 47
Top = 22
Left = 103
Top = 38
end
object CustomersTable: TFDQuery
Connection = Sqlite_demoConnection
FetchOptions.AssignedValues = [evRecordCountMode]
FetchOptions.RecordCountMode = cmTotal
SQL.Strings = (
'SELECT * FROM Customers')
Left = 47
Top = 85
Left = 103
Top = 101
end
object OrdersTable: TFDQuery
Active = True
Connection = Sqlite_demoConnection
FetchOptions.AssignedValues = [evRecordCountMode]
FetchOptions.RecordCountMode = cmTotal
SQL.Strings = (
'SELECT * FROM Orders'
'where CustomerID = :Cust')
Left = 49
Top = 147
Left = 105
Top = 163
ParamData = <
item
Name = 'CUST'
Expand All @@ -39,7 +36,7 @@ object SampleData: TSampleData
end>
end
object FDStanStorageBinLink1: TFDStanStorageBinLink
Left = 48
Top = 208
Left = 104
Top = 224
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ interface
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite,
FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.FMXUI.Wait,
FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt,
FireDAC.Stan.StorageBin, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client;
FireDAC.Stan.StorageBin, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
FireDAC.Phys.SQLiteWrapper.Stat;

type
TSampleData = class(TDataModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,51 +46,62 @@ object MasterDetail: TMasterDetail
object TeeGrid1: TTeeGrid
Columns = <
item
LoadOrder = 0
Header.Text = 'CustomerID'
Link = 'CustomerID'
end
item
LoadOrder = 1
Header.Text = 'CompanyName'
Link = 'CompanyName'
end
item
LoadOrder = 2
Header.Text = 'ContactName'
Link = 'ContactName'
end
item
LoadOrder = 3
Header.Text = 'ContactTitle'
Link = 'ContactTitle'
end
item
LoadOrder = 4
Header.Text = 'Address'
Link = 'Address'
end
item
LoadOrder = 5
Header.Text = 'City'
Link = 'City'
end
item
LoadOrder = 6
Header.Text = 'Region'
Link = 'Region'
end
item
LoadOrder = 7
Header.Text = 'PostalCode'
Link = 'PostalCode'
end
item
LoadOrder = 8
Header.Text = 'Country'
Link = 'Country'
end
item
LoadOrder = 9
Header.Text = 'Phone'
Link = 'Phone'
end
item
LoadOrder = 10
Header.Text = 'Fax'
Link = 'Fax'
end>
DataSource = DataSource1
ReadOnly = False
CellFormat = <>
Align = Client
Size.Width = 817.000000000000000000
Size.Height = 554.000000000000000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ procedure TMasterDetail.CBEnabledChange(Sender: TObject);
Expander.AlwaysExpand:=True;

// Set to first Column
TeeGrid1.Columns[0].Render:=Expander;

if TeeGrid1.Columns.Count>0 then
TeeGrid1.Columns[0].Render:=Expander;
end
else
begin
Expand Down

0 comments on commit 3ed2dff

Please sign in to comment.