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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Handle combo box control

Thread ID:

Created:

Updated:

Platform:

Replies:

125454 Aug 19,2016 11:21 AM UTC Aug 22,2016 09:45 AM UTC WinForms 1
loading
Tags: GridGroupingControl
sumudu
Asked On August 19, 2016 11:21 AM UTC

Hi,

Q1) How i can set a default value for combo box in add new record row.

Q2) There are 2 combobox type columns available in my GCC.I need to show/hide second combobox according to first combobox value.
How i can do this when i change the first combobox value.It is better if i can implement it within TableControlCurrentCellCloseDropDown event.
Image URL : combo box image

Thanks & Regards,
Sumudu EKanayake

Neelakandan Kannan [Syncfusion]
Replied On August 22, 2016 09:45 AM UTC

Hi Sumudu, 

Thanks for using Syncfusion products. 

Query 
How i can set a default value for combo box in add new record row. 

The reported scenario can be achieved by using the ShowDefaultValuesInAddNewRecord property and setting the default values for each columns using the Fields[“ColumnName”].DefaultValue property. Please make use of the below code, 
 
Code snippet 
this.gridGroupingControl1.ShowDefaultValuesInAddNewRecord = true; 
this.gridGroupingControl1.TableDescriptor.Fields["CategoryName"].DefaultValue = "Category12345"; 
this.gridGroupingControl1.TableDescriptor.Fields["Description"].DefaultValue = "Sample2"; 
this.gridGroupingControl1.TableDescriptor.Fields["CategoryID"].DefaultValue = "Sample1"; 
this.gridGroupingControl1.TableDescriptor.Fields["SampleData"].DefaultValue = "SampleData12345"; 
 
Query 
How I can do this when I change the first combobox value.It is better if I can implement it within TableControlCurrentCellCloseDropDown event. 


The reported scenario can be achieved by handling the QueryCellStyleInfo event. Here we have provided the sample in which “CategoryID” column combobox will be set to hide when “Description” column’s value is “Sample2”. Please make use of the below code, 

Code snippet 
this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); 
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity != null && e.TableCellIdentity.Column != null 
        && e.TableCellIdentity.Column.Name == "CategoryID" 
        && e.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record) 
    { 
 
        //Checks if the "Description" column is having value "Sample2" 
        if (e.TableCellIdentity.DisplayElement.GetRecord().GetValue("Description").ToString() == "Sample2") 
        { 
            //Hiding the ComboBox dropdown button 
            e.Style.ShowButtons = GridShowButtons.Hide; 
        } 
    } 
} 
 
 

Screenshot 
 

Sample 

Regards, 
Neelakandan 


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

;