DBGrid question (SOLVED) lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2012-01-05 09:08 I have a DBGrid attached to a datasource and I want to change the data that I see but I will not allow the user to create new lines. How can I do? ---------------------------------------------------------------------- ludob · 2012-01-05 09:27 Set dgDisableInsert to true in TDBGrid.Options ---------------------------------------------------------------------- xinyiman · 2012-01-05 10:03 Thank you ---------------------------------------------------------------------- xinyiman · 2012-01-05 10:08 Don't exist this propriety! ---------------------------------------------------------------------- ludob · 2012-01-05 10:25 Quote from: xinyiman on January 05, 2012, 11:08:19 amDon't exist this propriety!  lazarus 0.9.31 svn 34537. Don't know when it was introduced. Another approach would be to use the datasources OnStateChange event, detect if state = dsInsert and then Cancel. ---------------------------------------------------------------------- xinyiman · 2012-01-05 10:53 Ok thank you ---------------------------------------------------------------------- xinyiman · 2012-01-09 15:41 Quote from: ludob on January 05, 2012, 11:25:20 amQuote from: xinyiman on January 05, 2012, 11:08:19 amDon't exist this propriety!  lazarus 0.9.31 svn 34537. Don't know when it was introduced. Another approach would be to use the datasources OnStateChange event, detect if state = dsInsert and then Cancel. Error: unit_principale.pas(805,15) Error: Identifier not found "state" ---------------------------------------------------------------------- xinyiman · 2012-01-09 16:07 I solved with this code Abort; into BeforeInsert procedure! ---------------------------------------------------------------------- ludob · 2012-01-09 18:13 Quote from: xinyiman on January 09, 2012, 04:41:27 pmQuote from: ludob on January 05, 2012, 11:25:20 amAnother approach would be to use the datasources OnStateChange event, detect if state = dsInsert and then Cancel. Error: unit_principale.pas(805,15) Error: Identifier not found "state" State is a property of the datasource. So the full code would be: Code: [Select]if Datasource.State=dsInsert then Datasource.DataSet.Cancel; ---------------------------------------------------------------------- ludob · 2012-01-09 19:11 Quote from: xinyiman on January 09, 2012, 05:07:41 pmI solved with this code Abort; into BeforeInsert procedure! Hmm. And Ctrl-alt-del to close the form  Abort raises a silent exception and you never know exactly in what state you leave the program. Code is triggered here by an event (key or mouse events) and aborted with an exception. I checked the database code and I think in this case you are lucky. I haven't checked all possible cases though.