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

MultiColumnComboBox display columns

Hello,

I wanted to know how to be able to customize which columns will be displayed in the "MultiColumnComboBox" component. I did not find any properties to customize. If there is any option please inform me.

Ex: I have a table with several fields and only need to display 3 fields. "Code, Initial Value and Final Value"


Att,
Alan

3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team May 8, 2019 07:08 AM UTC

Hi Alan, 
 
Thanks for using Syncfusion product. 
 
You can able to customize which columns to be displayed in MultiSelectionComboBox by setting the MultiColumnComboBox1.ListBox.Grid.Model.Cols.Hidden[“Column Name”] to true. In which above property, you can able to set the true for the columns which you don’t want to show. Please find the below code snippet where totally 5 columns are available in table, but two columns are hidden. 
 
dt.Columns.Add("S.No"); 
dt.Columns.Add("FirstName"); 
dt.Columns.Add("LastName"); 
dt.Columns.Add("Occupation"); 
dt.Columns.Add("Place"); 
// Create a Data Set 
DataSet ds = new DataSet(); 
ds.Tables.Add(dt); 
dt.Rows.Add(new string[] { "1", "Alex", "Zen", "Doctor", "Italy" }); 
dt.Rows.Add(new string[] { "2", "Bob", "Harry", "Staff", "London" }); 
dt.Rows.Add(new string[] { "3", "Alice", "Peter", "Developer", "US" }); 
dt.Rows.Add(new string[] { "4", "Adlensha", "Fdo", "Staff", "Italy" }); 
dt.Rows.Add(new string[] { "5", "Brick", "John", "Nurse", "North America" }); 
dt.Rows.Add(new string[] { "6", "Collen", "Geo", "Developer", "India" }); 
this.multiColumnComboBox1.DataSource = dt; 
this.multiColumnComboBox1.DisplayMember = "Place"; 
this.multiColumnComboBox1.SelectedIndexChanged += new EventHandler(multiColumnComboBox1_SelectedIndexChanged); 
 
this.multiColumnComboBox1.ListBox.Grid.Model.Cols.Hidden["S.No"] = true; 
this.multiColumnComboBox1.ListBox.Grid.Model.Cols.Hidden["LastName"] = true; 
 
 
 
Please find the sample for your reference. 
 
Also refer the below documentation for your reference. 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan 



AO Alan Oliveira May 8, 2019 10:23 PM UTC

Hi Jagadeesan,

In my case I have a template "SimpleFrameFilter" as I determine which columns would be displayed without using the hidden method. I tried using the hidden plus the columns did not get organized 

Display: "FaixaInicial, FaixaFinal "

public class TabelaFaixaFatSimples : ModeloBase
    {
        [DataType(DataType.Currency)]
        public virtual decimal FaixaInicial { get; set; }
        [DataType(DataType.Currency)]
        public virtual decimal FaixaFinal { get; set; }
        public virtual decimal Aliquota { get; set; }
        public virtual decimal IRPJ { get; set; }
        public virtual decimal CSLL { get; set; }
        public virtual decimal COFINS { get; set; }
        public virtual decimal PIS_PASEP { get; set; }
        public virtual decimal CPP { get; set; }
        public virtual decimal ICMS { get; set; }
        public virtual decimal IPI { get; set; }
        public virtual decimal ISS { get; set; }
        public virtual decimal PercReducaoBC { get; set; }
}


SR Sabaridass Ramamoorthy Syncfusion Team May 9, 2019 09:38 AM UTC

Hi Alan, 

Sorry for the inconvenience caused. 

By default, you can hide the column by setting the Browsable attribute as false. To display the specific column, you could change the Browsable attribute as true for that specified column. Please refer the following code example. 

C# 
List<String> SimpleFrameFilter = new List<String>(); 
SimpleFrameFilter.Add("FaixaInicial"); 
SimpleFrameFilter.Add("FaixaFinal"); 
this.changeBrowsableAttribute(typeof(TabelaFaixaFatSimples), SimpleFrameFilter); 
this.multiColumnComboBox1.DataSource = collection; 
 
private void changeBrowsableAttribute(Type wallTypeToMakeSheathingVisible, List<String> columns) 
{ 
    foreach (var col in columns) 
    { 
        PropertyDescriptor descriptor = TypeDescriptor.GetProperties(wallTypeToMakeSheathingVisible)[col]; 
        BrowsableAttribute attrib = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)]; 
        FieldInfo isBrow = attrib.GetType().GetField("browsable", BindingFlags.NonPublic | BindingFlags.Instance); 
        isBrow.SetValue(attrib, true); 
    } 
} 
 
public class TabelaFaixaFatSimples 
{ 
    [Browsable(false)] 
    public virtual decimal FaixaInicial { get; set; } 
    [Browsable(false)] 
    public virtual decimal FaixaFinal { get; set; } 
    [Browsable(false)] 
    public virtual decimal Aliquota { get; set; } 
    [Browsable(false)] 
    public virtual decimal IRPJ { get; set; } 
    [Browsable(false)] 
    public virtual decimal CSLL { get; set; } 
    [Browsable(false)] 
    public virtual decimal COFINS { get; set; } 
    [Browsable(false)] 
    public virtual decimal PIS_PASEP { get; set; } 
    [Browsable(false)] 
    public virtual decimal CPP { get; set; } 
    [Browsable(false)] 
    public virtual decimal ICMS { get; set; } 
    [Browsable(false)] 
    public virtual decimal IPI { get; set; } 
    [Browsable(false)] 
    public virtual decimal ISS { get; set; } 
    [Browsable(false)] 
    public virtual decimal PercReducaoBC { get; set; } 
} 
 
 
Please get back to us if you need any further assistance on this. 

Regards, 
Sabaridass R 


Loader.
Live Chat Icon For mobile
Up arrow icon