Search code examples
delphidelphi-7

How do I determine if a DBGrid is in insert mode


I want to display another control only if a DBGrid is in insert mode. How can I detect if DBGrid or the connected DBNavigator or TQuery is in insert mode?

Thank you


Solution

  • You check to see what State the underlying (connected) TDataSet is in (TDataSet.State), using TDataSource.State.

    if DBGrid1.DataSource.State = dsInsert then   // It's in insert mode
    

    There's also dsEdit to tell you if it's being edited, dsBrowse to let you know the DataSet is just being viewed, and some others.