10800 : Catching events in inplace edit boxes

Question

I need to know how to fill a combotext (editbox) in the grid (possible without an event ?) and after i need to know how to get a value from that combotextbox after I have selected one item from it by mouse.

Today I only can fill the box with that grid1_OnBeforeEditCell event and I only can retrieve a box value after i have selected one by mouse and additionaly pressed enter.

Answer

You will need to use the event, but you can also hook up event listeners in this event on your combobox. This way you can react to any action taken in the inplace edit box:


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");
           (beforeEdit.Cell.Content as ComboText).EditBox.SelectedIndexChanged += new EventHandler(EditBox_SelectedIndexChanged);
  }
  else
  {
     if (beforeEdit.Cell.Content is SingleText)
     {
        (beforeEdit.Cell.Content as SingleText).EditBox.TextChanged += new EventHandler(EditBox_TextChanged);
     }

}

}

    void EditBox_SelectedIndexChanged(object sender, EventArgs e)
    {
      // Tell someone that the index changed
    }

    void EditBox_TextChanged(object sender, EventArgs e)
    {
      (sender as TextBox).ForeColor=Color.Green;
    }