We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Multi-column combo box in a gdbg

Hello, I tried to use as a multi-column combo box in a GridDataBoundGrid but I could not find a good example. 
I would like to show in a grid column a multi-column combo box with data from a DataTable that is not connected to the grid, 
how can I do? 
Thank you very much
Roberto Guerzoni

4 Replies

MS Maniratheenam Sehar Syncfusion Team July 18, 2014 03:58 AM UTC

Hi Roberto Guerzoni,

 

Thank you for your interest in Syncfusion Products.

 

Query:

Multi-column combo box in a gdbg

We Would like to convey that reported query can be resolved by using GridPreviewstyleinfo event. In which by setting, the celltype as GridListControl, you can easily obtain MultiColumnCombobox in GridDataBound control.

For your better understanding, CodeSnippet is given below,

 

void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)

        {

 

           if (e.ColIndex == 2 && e.RowIndex == 3)

            {

                e.Style.CellType = GridCellTypeName.GridListControl;

                e.Style.DataSource = USStates();

                e.Style.CellValue = "US";

                e.Style.DisplayMember = "LongName";

                e.Style.ValueMember = "ShortName";

            }

        }

 

For your better convenience, we’ve added a sample below,

http://www.syncfusion.com/downloads/support/directtrac/126914/gbg-991142667.zip

 

 

Please let us know, if you’ve any further concerns.

 

Regards,

ManiRatheenam S



RG Roberto Guerzoni July 18, 2014 07:30 AM UTC

Great job, thank you very much
You are fantastic support


RG Roberto Guerzoni July 18, 2014 11:57 AM UTC

Hi Maniratheenam
I used the feature in a slightly different way, If it can be useful to someone here is the code that is used

public StationsForm()
{
....
//
// Format the columns in the DataTable that we will use in GridListControl associated with the column RackId
//
m_ioRacksViewDataTable.Columns["RackId"].ColumnName = CommonResource.RackId;
m_ioRacksViewDataTable.Columns["Description"].ColumnName = CommonResource.Description;
m_ioRacksViewDataTable.Columns["IPAddress"].ColumnName = CommonResource.IPAddress;
m_ioRacksViewDataTable.Columns.Remove( "IPPort" );
m_ioRacksViewDataTable.Columns.Remove( "Node" );
m_ioRacksViewDataTable.Columns.Remove( "SlaveKind" );
m_ioRacksViewDataTable.Columns.Remove( "ModbusSlaveId" );
....
}

private void StationsForm_Load( object sender, EventArgs e )
{
if( !m_initialized )
{
m_initialized = true;


assemblyStationsGrid.BeginUpdate();
assemblyStationsGrid.Binder.InternalColumns["StationId"].Position = 1;
assemblyStationsGrid.Binder.InternalColumns["StationId"].Width = 100;
assemblyStationsGrid.Binder.InternalColumns["Description"].Position = 2;
assemblyStationsGrid.Binder.InternalColumns["Description"].Width = 500;
assemblyStationsGrid.Binder.InternalColumns["IPAddress"].Position = 3;
assemblyStationsGrid.Binder.InternalColumns["IPAddress"].Width = 150;
assemblyStationsGrid.Binder.InternalColumns["RackId"].Position = 4;
assemblyStationsGrid.Binder.InternalColumns["RackId"].Width = 150;
assemblyStationsGrid.Binder.InternalColumns["CS1PositionSwitch"].Position = 5;
assemblyStationsGrid.Binder.InternalColumns["CS1PositionSwitch"].Width = 150;
assemblyStationsGrid.Binder.InternalColumns["CS2PositionSwitch"].Position = 6;
assemblyStationsGrid.Binder.InternalColumns["CS2PositionSwitch"].Width = 150;


var style = assemblyStationsGrid.Binder.InternalColumns["RackId"].StyleInfo;
style.CellType = GridCellTypeName.GridListControl; // TIP - MultiColumnComboBox
style.DropDownStyle = GridDropDownStyle.Exclusive; TIP - Comment out the line if you want to allow editing of the column
style.DataSource = m_ioRacksViewDataTable;
style.DisplayMember = CommonResource.RackId;
style.ValueMember = CommonResource.RackId;
//style.ShowButtons = GridShowButtons.ShowCurrentRow; // TIP-Uncomment theline if you want the grid to display the selection buttons only in selected row
style.HorizontalAlignment = GridHorizontalAlignment.Left;
assemblyStationsGrid.EndUpdate();
}
}


MS Maniratheenam Sehar Syncfusion Team July 21, 2014 05:43 AM UTC

Hi Roberto Guerzoni,

 

Thanks for the update.

We are glad that your issue has been resolved.

 

Regards,

ManiRatheenam S


Loader.
Live Chat Icon For mobile
Up arrow icon