DataGrid Inplace Combobox events

I am using an inplace combobox like this:

Items:=TStringList.Create;
Items.Add('h');
Items.Add('e');
Items.Add('l');
Items.Add('l');
Items.Add('o');

Grid.Columns[0].Editor:=getComboEdit;
Grid.Columns[0].EditorItems:=Items;

Is there an event fired when clicking onto an item?

That would be important because the user selects an item, the combobox closes and nothing happens?

Hi, there is no event triggered, the combobox remains visible. Can you explain more in detail what exactly you need to do with this event? There is an additional event triggered OnAfterCloseInplaceEditor when the combobox exits and posts the value to the cell.

Hi,

I still can not see a combobox before clicking 3 times on the cell:

  • start app - no combobox visible in grid
  • 1st click on cell - cell gets selcted - no combobox
  • 2nd click on cell - combobox visible but closed
  • 3rd click on cell - combobox opens

Big problem: First time users dot not even know that there is a combobox. They won’t click on that cell.

Then I select an item

  • combobox closes and selected item and combobox visible
  • no event triggered

In this state, the UI is not consistent.

Example:

Combobox to select count of order, next colum price of order.

I change from 1 pizza to two but the price will not update before clicking in another cell or exit. In my opinion that will not be accepted by users…

For the event issue a solution is:

procedure TFormTestFNCMain.GridGetInplaceEditorProperties(Sender: TObject; ACell: TTMSFNCDataGridCellCoord; AInplaceEditor: TTMSFNCDataGridInplaceEditor; AInplaceEditorType: TTMSFNCDataGridInplaceEditorType);

begin

(AInplaceEditor as TComboBox).OnChange:=OnComboBoxChange;

end;

procedure TFormTestFNCMain.OnComboBoxChange(Sender: TObject);
begin

end;

Hi,

There are options to immediately show the combobox, and also immediately let it dropdown the list:

TMSFNCDataGrid1.Options.Editing.DirectDropDown := True;
TMSFNCDataGrid1.Options.Mouse.DirectEdit := True;

You can indeed use the event if you want to let the user know he made a selection, but as long as the editor remains active, the value will not be posted to the cell. It’s not possible to automatically close the inplace editor when a value is selected, you will get an access violation because there are still things happening after the OnChange event inside TComboBox that prevents from doing this, unless you start a close timer from the OnChange event, and then call TMSFNCDataGrid1.StopEditing to accept the value the user selected.

Hi,

that works pretty well. I use a 200ms timer to close the combobox in its closeup event.

Unfortunately the combobox is still not permanently visible, but may be I will add a hint to that cells…

Yes, unless you use the Controls[] and hook up events it will not be permanently visible unfortunately.