Home Forums WinForms controls Xceed Grid for WinForms use customcomboDropdown in Grid cell editor

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15766 |

    I would like to use your sample “CustomcomboDropdown”, which bound to a dataset, as a grid cell editor control.

    The problem I am facing is: the default grid cell editor is textbox. I add the CustomcomboDropdown control to the celManager templatecontrol, but can’t change the default control or remove the textbox control.

    When the leavingEdit event is fired, the return new value always from the textbox , not from
    my CustomComboDropdown.

    How could I solve this problem?

    Appreciate your help

    Imported from legacy forums. Posted by zuqiang (had 1913 views)

    Xceed Support
    Member
    Post count: 5658

    You need to instantiate the CellEditorManager with the new CustomComboDropDown.

    Here is the code I used (it will get a CustomComboDropDown in every cell of the second column):

    The code from the Load_Form:

    <code>
    private void Form1_Load( object sender, EventArgs e )
    {
    Column col1 = new Column( “Column1” );
    Column col2 = new Column( “Column2” );
    gridControl1.Columns.Add( col1 );
    gridControl1.Columns.Add( col2 );

    CustomComboDropDown ccdd = new CustomComboDropDown( EnhancedBorderStyle.None );

    gridControl1.Columns[ “Column2” ].CellEditorManager = new CellEditorManager( ccdd,
    “Text”, true, true );

    for( int i = 0; i < 20; i++ )
    {
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    row.Cells[ 0 ].Value = “Item ” + i.ToString();
    row.EndEdit();
    }
    }
    </code>

    The code from the CustomComboDropDown class:

    <code>
    public class CustomComboDropDown : WinComboBox
    {
    public CustomComboDropDown()
    : base()
    {
    StartMethod();
    }

    protected CustomComboDropDown( CustomComboDropDown template )
    : base( template )
    {
    StartMethod();
    }

    public CustomComboDropDown( EnhancedBorderStyle ebs )
    : base( ebs )
    {
    StartMethod();
    }

    private void StartMethod()
    {
    this.DataSource = this.FillData().Tables[ 0 ];

    this.DropDownControl.FixedHeaderRows.Add( new GroupByRow() );
    this.DropDownControl.FixedHeaderRows.Add( new ColumnManagerRow() );

    Group groupShipCountry = new Group( “ShipCountry” );
    groupShipCountry.Collapsed = true;
    this.DropDownControl.GroupTemplates.Add( groupShipCountry );

    Group groupShipCity = new Group( “ShipCity” );
    groupShipCity.Collapsed = true;
    this.DropDownControl.GroupTemplates.Add( groupShipCity );

    this.DropDownControl.UpdateGrouping();

    this.DropDownSize = new System.Drawing.Size( 500, 250 );
    this.DropDownControl.ScrollBars = GridScrollBars.ForcedHorizontal;
    this.DropDownControl.RowSelectorPane.Visible = true;

    this.Location = new System.Drawing.Point( 10, 10 );
    }

    private DataSet FillData()
    {
    OleDbConnection connection = new OleDbConnection( “NorthwindConnectionString” );
    connection.Open();
    OleDbDataAdapter dataAdapter = new OleDbDataAdapter( “SELECT * FROM ORDERS”, connection );
    DataSet data = new DataSet();
    dataAdapter.Fill( data );
    connection.Close();

    return data;
    }
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 3010 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.