Sfdatagrid gridcomboboxcolumn set datasource

hi,

I'm developing a winForms project in VS 2019,

I added column from properties columns.

1- I want to set datasource , displaymember,valuemember programatically.how can i do?

2-can i add different items for each row.If its possible , how can i do?

thanks for help



3 Replies

VS Vijayarasan Sivanandham Syncfusion Team January 27, 2022 01:20 PM UTC

Hi Serdar,

Please find answer for your queries below 
Queries 
Solutions 
 
I want to set datasource , displaymember,valuemember programatically.how can i do? 
 
 
Your requirement to set datasource , displaymember and valuemember programmatically in GridComboBoxColumn can be achieved by getting the GridComboBoxColumn by using MappingName and customize like below mentioned code snippet, 
Private Sub OnSetDataSourceClicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSetDataSource.Click 
                'get the ComboBoxColumn 
                Dim comboBoxColumn = TryCast(Me.sfDataGrid.Columns("ShipCityID"), GridComboBoxColumn) 
                'set the DataSource for GridComboBoxColumn 
                comboBoxColumn.IDataSourceSelector = New CustomSelector() 
                'set the DisplayMember for GridComboBoxColumn 
                comboBoxColumn.DisplayMember = "ShipCityName" 
                'set the ValueMember for GridComboBoxColumn 
                comboBoxColumn.ValueMember = "ShipCityID" 
End Sub 

For more information related to GridComboBoxColumn, please refer the below user guide documentation link,

UG Link : https://help.syncfusion.com/windowsforms/datagrid/columntypes?cs-save-lang=1&cs-lang=vb#gridcomboboxcolumn
 
 
can i add different items for each row.If its possible , how can i do? 
 
 
Yes. Different data sources can be loaded for each row of the GridComboBoxColumn by using the DataSourceSelector property. For more information related to Loading different DataSources for each row, please refer the below user guide documentation link,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/columntypes?cs-save-lang=1&cs-lang=vb#loading-different-datasources-for-each-row-of-gridcomboboxcolumn
 

Sample Link: https://www.syncfusion.com/downloads/support/forum/172307/ze/SfDataGridDemo-57896400

Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 



SA Sergio Ayala July 28, 2022 08:58 AM UTC

Hi, I am implementing different source for each column combobox. I am using "DataSourceSelector" and it works perfect for me. The problem I have is that the source of each comobox needs to be filled only when the user displays the combobox, also the method is async and I can't use it inside the " public IEnumerable GetDataSource(object record, object dataSource)" method 



SP Sangavi Periyannan Syncfusion Team July 29, 2022 12:45 PM UTC

Hi Sergio, 


It seems you have created a new forum for this same query. Kindly have further follow-ups for this query in the forum thread 176510. 


Regards,

Sangavi


Loader.
Up arrow icon