Search code examples
delphidevexpresslookupdelphi-xe5maskedtextbox

TMaskEdit LookUpComboBox Behaviour


I have a dev express grid dbtableview where I defined a column as maskedit. On InitEdit I populate the LookItems list for a specific record (item).

The question is if I can restrict the user to introduce only the values that match the LookItems for the specific record, instead of changing the whole column property to LookUpComboBox ?


Solution

  • You will need a component called cxEditRepository, add LookupComboBox to Repository on your cxDBColumn use the event OnGetProperties

    In this example, my column is called 'text'

    procedure TForm2.cxGrid1DBTableView1TextGetProperties(
      Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
      var AProperties: TcxCustomEditProperties);
    begin
      if ARecord.Values[cxGrid1DBTableView1Text.Index] = 'value2' then
        AProperties:= cxEditRepository1LookupComboBoxItem1.Properties;
    end;
    

    I hope this has helped