0
votes

I have a custom DateTimePicker control that prepared for Persian calendar. Is there any way to add it to the DevExpress GridControl column? Please help me.

1

1 Answers

1
votes

From: Creating a custom (RepositoryItem) ImageComboBox

If you wish to use your custom control in GridControl, it is necessary to create an editor and its RepositoryItem descendants.

Please refer to the Custom Editors and How to register a custom editor for use in the XtraGrid articles for complete information on how to create custom controls. You can find some custom editor descendants in our examples: editor descendants.

The RepositoryItem class contains editor settings and is used as a template for cells in the grid. In the display mode, GridControl only draws cells content via RepositoryItem's methods. In the edit mode, GridControl creates a corresponding editor via the RepositoryItem.CreateEditor method. Thus, if you wish to add items to the editor used in the grid on its initialization, implement this at the RepositoryItem level.

You can set an editor for the auto filter row if you handle GridView.CustomRowCellEdit event with following code

    RepositoryItemDateEdit rd = new RepositoryItemDateEdit();
    void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) {
      GridView view = sender as GridView;
      if(e.Column.FieldName == "DOB" && view.IsFilterRow(e.RowHandle)) {
          e.RepositoryItem = rd;
      }
    }

Review the Assigning Editors to Columns and Card Fields help article to learn how to assign a specific editor to a particular GridView's column.

I hope you will find this information useful.