Domanda

Inside of Dev Express grid table view I have a bounded column (string type) defined as maskedit (property) from visual form. (Design, DeveloperExpressGrid).

If I define the editmask from visual form, it works as it should.

What I want is to define the editmask specific for each record, not for the entire column. That is why I try to access the editmask property from code side on columnPropertiesChange event.

The problem is that when I call from code the column.property is CustomEdit, and therefore without any editmask property.

There is a way to access the editmask property from behind code?

È stato utile?

Soluzione

You can use the InitEdit event of your view to change the mask for AEdit given as parameter since the default editor is TcxCustomMaskEdit. The needed column might be resolved from AItem.Index the Row can be found through Sender.DataController, depending of your databinding.

procedure TForm3.cxGrid1DBTableView1InitEdit(
  Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
  AEdit: TcxCustomEdit);
begin
  if AEdit is TcxCustomMaskEdit then // default editor if no other editor defined
  begin
  // your condition for row and column (here just toggeling)
  if ( Sender.DataController.FocusedRecordIndex AND 1) = 1 then
      TcxCustomMaskEdit(AEdit).Properties.EditMask := '###..####'
  else
      TcxCustomMaskEdit(AEdit).Properties.EditMask := '******';
  end;
end;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top