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

get valuemember of Combobox in GridGroupingControl

I have a coulmn style Combobox in Gridgroupingcontrol :

grid_HangHoa_DinhLuong.TableDescriptor.GetColumnDescriptor("TEN_NGUYENLIEU").Appearance.AnyRecordFieldCell.DataSource = lst_hh;
grid_HangHoa_DinhLuong.TableDescriptor.GetColumnDescriptor("TEN_NGUYENLIEU").Appearance.AnyRecordFieldCell.DisplayMember = "TEN";
 grid_HangHoa_DinhLuong.TableDescriptor.GetColumnDescriptor("TEN_NGUYENLIEU").Appearance.AnyRecordFieldCell.ValueMember = "ID";

How to get valuemember of selected item of combobox ?

And in my event RecordValueChanged , when i changed item of other column , how to get valuemember of this combobox ?
I only can get the combobox text 

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team December 19, 2016 11:50 AM UTC

Hi Truong, 

Thanks for using Syncfusion products. 

Currently we do not have the direct support to get the value member of ComboBox column when changing the other item column values. But you can achieve your scenario by handling the RecordValueChanged event and use the Dictionary collection(values) to save the DisplayMember values and ValueMember values of ComboBox to achieve your scenario. Please refer the below code snippet and refer the attached sample 

Code snippet: 
this.gridGroupingControl1.Table.RecordValueChanged += Table_RecordValueChanged; 
 
Dictionary<string, string> values = new Dictionary<string, string>(); 
 
void Table_RecordValueChanged(object sender, Syncfusion.Grouping.RecordValueChangedEventArgs e) 
{ 
    Record record = e.Record; 
    GridTableCellStyleInfo style = (record.ParentTable as GridTable).GetTableCellStyle(record, "Name"); 
 
    DataTable combo = style.DataSource as DataTable; 
    this.ComboBoxDisplayMemberValues(combo); 
    string valuemember = values.ContainsKey(style.FormattedText.ToString()) ? values[style.FormattedText.ToString()].ToString() : string.Empty; 
    MessageBox.Show("Combo box value member value:" + valuemember); 
} 
 
private void ComboBoxDisplayMemberValues(DataTable dt) 
{ 
    if (dt != null) 
    { 
        foreach (DataRow dr in dt.Rows) 
        { 
            if (!values.ContainsKey(dr[0].ToString())) 
                values.Add(dr[0].ToString(), dr[1].ToString()); 
        } 
    } 
} 
 
Sample link: GridGroupingControl 
 
Regards, 
Mohanraj G.  


Loader.
Up arrow icon