Home Forums WinForms controls Xceed Grid for WinForms Adding a ComboBox to a column Reply To: Adding a ComboBox to a column

User (Old forums)
Member
Post count: 23064

Thanks André for your attention. No, i don’t get any exception and none is swallowed by the framework.

 This is my code:

//Checkbox 

grid.Columns.Add(

new Column(“chkPublicar”, typeof(bool)));

grid.Columns[“chkPublicar”].CellViewer =

new Xceed.Grid.Editors.GridCheckBox();

grid.Columns[“chkPublicar”].CellEditor =

new Xceed.Grid.Editors.GridCheckBox();

//Combobox 

grid.Columns.Add(

new Column(“cmbOrden”, typeof(int)));

grid.AddingDataRow +=

new AddingDataRowEventHandler(grid_AddingDataRow);

grid.ReadOnly =

false;

grid.SingleClickEdit =

true;

grid.Columns[“chkPublicar”].ReadOnly =

false;

grid.Columns[“cmbOrden”].ReadOnly =

false;

 

private void grid_AddingDataRow(object sender, AddingDataRowEventArgs e)

{

e.DataRow.Cells[“chkPublicar”].Value = (estado == 2);

e.DataRow.Cells[“chkPublicar”].Click +=

new EventHandler(chkPublicar_Click);

Xceed.Grid.Editors.GridComboBox cmb =

new Xceed.Grid.Editors.GridComboBox();

cmb.Items.Add(1);

cmb.Items.Add(2);

cmb.Items.Add(3);

cmb.SelectedIndex = 1;

cmb.Enabled =

true;

cmb.Visible =

true;

cmb.DropDownStyle = ComboBoxStyle.DropDownList;

cmb.DropDownWidth = 40;

cmb.SelectedIndexChanged +=

new EventHandler(cmb_SelectedIndexChanged);

e.DataRow.Cells[“cmbOrden”].CellViewer = cmb;

e.DataRow.Cells[“cmbOrden”].CellEditor = cmb;

}

 

I use Click event because i don’t know how to trigger the CheckedChanged event

private void chkPublicar_Click(object sender, EventArgs e)

{

bool valor = Convert.ToBoolean(((Xceed.Grid.DataCell)sender).Value);

((Xceed.Grid.DataCell)sender).Value = !valor;

}

private void cmb_SelectedIndexChanged(object sender, EventArgs e)        //<=== Never fired

{

int idx = ((Xceed.Grid.Editors.GridComboBox)sender).SelectedIndex;

Console.WriteLine(idx.ToString());

}

What i’m doing wrong?

 Thanks. 

 

Imported from legacy forums. Posted by Javier (had 690 views)