How to save each item from selected index in a variable?

I have a multicolumn combo box with 5 columns. When i select one item from the list i need to save each item from the row in a different variable for later use. Is there a way to do this?

1 Reply

KR Kannan R Syncfusion Team August 27, 2018 06:44 AM UTC

Hi Nikos 
 
Thank you for contacting Syncfusion Support.  
 
Yes, it is possible to achieve this requirement using SelectedItem property and SelectedIndexChanged event of MultiColumnComboBox. As like your expectation, here we have added Selected Row information in SelectedRowsCollection property and from which you can be able to retrieve the value for each column in Selected Row.  
 
Please make use of below code snippet as reference.  
 
Code Snippet : [C#] 
 
 
        //Collection to hold Selected Row information 
        List<SelectedRowInformation> SelectedRowsCollection = new List<SelectedRowInformation>(); 
 
        /// <summary> 
        /// This event occurs when SelectedIndex is modified.  
        /// </summary> 
        void multiColumnComboBox1_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            // Here we are adding selected row information for all rows in MultiColumnComboBox 
            if (this.multiColumnComboBox1.SelectedItem != null && this.multiColumnComboBox1.SelectedItem is DataRowView) 
            { 
                DataRowView selectedRow = this.multiColumnComboBox1.SelectedItem as DataRowView; 
                this.SelectedRowsCollection.Add(new SelectedRowInformation(selectedRow.Row["S.No"].ToString(), selectedRow.Row["FirstName"].ToString(),  
                selectedRow.Row["LastName"].ToString(), selectedRow.Row["Occupation"].ToString(),  selectedRow.Row["Place"].ToString())); 
            } 
        } 
 
 
 
 
As we are not aware of your DataSource information, we have considered it as DataTable and provided this suggestion. Kindly check and let us know if it is helpful.  
 
Regards 
Kannan  


Loader.
Up arrow icon