0

I have successfully created a grid with parent rows which can be expanded into a child row. I would like to have a combobox in a column in the child row which has different items depending on values in the parent row. How can I populate the comboboxes differently for each child row?

What I need is a way of getting the parent row at the same time as the combobox in the child row. I can't seem to find an event or property which can access one from the other.

Michael Sandler
  • 1,290
  • 3
  • 17
  • 30
  • Can you show the code that you have currently..? start looking here for example http://stackoverflow.com/questions/5311178/adding-items-to-a-combobox-in-datagridview – MethodMan Jan 21 '13 at 18:21
  • 1
    Check this link as well [Column Types in the Windows Forms DataGridView Control](http://msdn.microsoft.com/en-us/library/bxt3k60s.aspx) – MethodMan Jan 21 '13 at 18:28

1 Answers1

1

Hours later, I found this. I used the CustomRowCellEdit on my GridView event

  myGridView.CustomRowCellEdit += new CustomRowCellEditEventHandler(myGridView_CustomRowCellEdit);

which will give you the row

void myGridView_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
  myRowType myRow = (sender as GridView).GetRow(e.RowHandle) as myRowType;

and you can make a new editor like so

  RepositoryItemComboBox editor = new RepositoryItemComboBox();
  editor.Items.AddRange(myRow.AllowedValues);
  e.RepositoryItem = editor;

Trying to modify an existing editor (combobox or otherwise) will not work.

Michael Sandler
  • 1,290
  • 3
  • 17
  • 30
  • http://www.devexpress.com/Support/Center/Example/Details/E737 shows a good option also using gridView_ShownEditor event – FabianSilva Oct 12 '13 at 15:28