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

Unfortunately, we can’t identify the issue.  We have tried the following code, and it works fine in with version 3.2 using a 2.5 license key :

 

    public Form1()

    {

      Xceed.Grid.Licenser.LicenseKey = “GRD25…”;

      InitializeComponent();

    }

 

   

private void Form1_Load( object sender, EventArgs e )

    {

      GridControl gridControl = new GridControl();

      gridControl.SingleClickEdit = true;

      gridControl.FixedHeaderRows.Add( new ColumnManagerRow() );

      gridControl.Dock = DockStyle.Fill;

      this.Controls.Add( gridControl );

 

      //Checkbox

 

      gridControl.Columns.Add( new Column( “chkPublicar”, typeof( bool ) ) );

      gridControl.Columns[ “chkPublicar” ].CellViewer = new Xceed.Grid.Editors.GridCheckBox();

      gridControl.Columns[ “chkPublicar” ].CellEditor = new Xceed.Grid.Editors.GridCheckBox();

 

      //Combobox

      gridControl.Columns.Add( new Column( “cmbOrden”, typeof( int ) ) );

      gridControl.AddingDataRow += new AddingDataRowEventHandler( gridControl_AddingDataRow );

 

 

      gridControl.DataRows.AddNew().EndEdit();

 

    }

 

    private void gridControl_AddingDataRow( object sender, AddingDataRowEventArgs e )

    {

      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;

    }

 

    private void cmb_SelectedIndexChanged( object sender, EventArgs e )

    {

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

 

      Debug.WriteLine( idx.ToString() );

    }

 

 

Imported from legacy forums. Posted by André (had 664 views)