10160 : How can I fill a comboBox for a Column?

Question

I must provide custom values from DB to a grid columm, so my users can choose one. This list can change over time.
VCL edition.
Thanks.

Answer

The inplace-edit-combobox often must have different values depending on what column or row it pops up.

There is an event that fires just before the edit starts. In this event you may change the content in the combobox depending on focused cell.

In the phGantTimePackage OCX this event is called IphGantX3.OnBeforeCanEditGrid
You the call IphGantX3.GridEditComboClear and IphGantX3.GridEditComboAdd

In the phGantTimePackage VCL this event is called phGant.Grid.OnEditorCanModify, but there is another event that only fires when a combo edit is started: phGant.Grid.OnBeforeEditWithCombo.
You can then use phGant.Grid.InitEditCombo to update values

In GTP.NET the event is called Gantt.Grid.OnBeforeEditCell, and you can fill the combobox with data like this:

private void grid1_OnBeforeEditCell(PlexityHide.GTP.Grid grid, PlexityHide.GTP.BeforeEditEventArgs beforeEdit)
{

  if (beforeEdit.Cell.Content is ComboText)
  {
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Clear();
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 1”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 2”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 3”);
    (beforeEdit.Cell.Content as ComboText).EditBox.Items.Add(“Item 4”);
  }

}

 

Leave a Reply