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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

get valuemember of Combobox in GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

127896 Dec 16,2016 08:36 AM UTC Dec 19,2016 11:50 AM UTC Windows Forms 1
loading
Tags: GridGroupingControl
Truong
Asked On December 16, 2016 08:36 AM UTC

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 

Mohanraj Gunasekaran [Syncfusion]
Replied On 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.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;