This is a migrated thread and some comments may be shown as answers.

MultiColumn in Display

6 Answers 220 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 05 Apr 2014, 05:30 PM
Hi

How to do i Display multiple fields in Display/Select Box?

Basically  is there way do display selected row, instead of just one filed Selected Filed

Thank you.

6 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 09 Apr 2014, 03:05 PM
Hello Boris,

Thank you for writing.

If I understand your requirement correctly, you are trying to display the multiple cell values from the currently selected row in the popup grid inside the editable part of the RadMultiColumnComboBox. This functionality is not supported our of the box.

The multi-column combobox is a special case of combobox control with RadGridView integrated in its drop-down. The control combines the functionality and features of RadComboBox and RadGridView. According to the DisplayMember property, you are allowed to display only one cell value according to the current selection. You can customize the default behavior and display several values in the text area via custom MultiColumnComboGridBehavior.  Here is a sample code snippet, demonstrating how to achieve it:
private void Form1_Load(object sender, EventArgs e)
{
    this.productsTableAdapter.Fill(this.nwindDataSet.Products);
     
    this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRowChanged += EditorControl_CurrentRowChanged;
    this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.GridBehavior = new CustomMultiColumnComboGridBehavior();
    this.radMultiColumnComboBox1.DataSource = this.productsBindingSource; 
}
 
private void EditorControl_CurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e)
{
    StringBuilder sb = new StringBuilder();
    foreach (GridViewCellInfo cell in e.CurrentRow.Cells)
    {
        sb.AppendFormat("{0} | ", cell.Value);
    }
    radMultiColumnComboBox1.MultiColumnComboBoxElement.Tag = sb.ToString();
    radMultiColumnComboBox1.MultiColumnComboBoxElement.Text = sb.ToString();
}
 
public class CustomMultiColumnComboGridBehavior : MultiColumnComboGridBehavior
{
    public override bool OnMouseUp(MouseEventArgs e)
    {
        bool result = base.OnMouseUp(e);
 
        MultiColumnComboPopupForm popupForm = this.GridViewElement.ElementTree.Control.Parent as MultiColumnComboPopupForm;
        RadMultiColumnComboBoxElement multiComboBoxElement = popupForm.OwnerElement as RadMultiColumnComboBoxElement;
        if (multiComboBoxElement.Tag != null && multiComboBoxElement.Text != multiComboBoxElement.Tag)
        {
            multiComboBoxElement.Text = multiComboBoxElement.Tag.ToString();
            multiComboBoxElement.Tag = null;
        }
         
        return result;
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
fabrizio
Top achievements
Rank 1
Veteran
answered on 12 May 2017, 07:04 PM

Hi Dess
I was also looking for a way to show more cells in the text field of the radMulticolumn combo.

I use vb.net and do not understand how to translate the code

"This.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRowChanged + = EditorControl_CurrentRowChanged;"

From c # to vb.net.
Can you help me please?
Thank you
Fabrizio

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 May 2017, 11:27 AM
Hello Fabrizio, 

Thank you for writing.  

In order to subscribe to the CurrentRowChanged event in VB.NET, you can use the following code snippet:  
Sub New()
    InitializeComponent()
    AddHandler Me.RadMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRowChanged, AddressOf CurrentRowChanged
End Sub
 
Private Sub CurrentRowChanged(sender As Object, e As Telerik.WinControls.UI.CurrentRowChangedEventArgs)
    'TODO
End Sub

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
fabrizio
Top achievements
Rank 1
Veteran
answered on 18 May 2017, 02:18 PM

Hello Dess thank you so much for your code, works fine on the currentRowChanged event.
Sorry I wanted to ask if is possible to show more cells in the text even during the on_load form event ?
With the Visual Studio Combobox I was concatenating the columns with a cycle for each, but with the MultiColumnComboBox I can not figure out how to do it and if it can be done.
Thank you
Fabrizio

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 May 2017, 08:23 AM
Hello Fabrizio, 

Thank you for writing back. 

If I understand your requirement correctly, you are trying to display more than one fields in the editable part of RadMultiColumnComboBox. Note that the DisplayMember property controls what to be displayed. But it is designed to specify only one field. The possible solution that I can suggest is to create an additional field that will store the concatenated data and use that field as DisplayMember. Here is a sample code snippet: 
Dim dt As New DataTable
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("ConcatenatedField", GetType(String))
For index = 1 To 10
    dt.Rows.Add(index, "Item" & index, index & "Item" & index)
Next
Me.RadMultiColumnComboBox1.DataSource = dt
Me.RadMultiColumnComboBox1.DisplayMember = "ConcatenatedField"
Me.RadMultiColumnComboBox1.ValueMember = "Id"
Me.RadMultiColumnComboBox1.EditorControl.Columns("ConcatenatedField").IsVisible = False

If it is not the exact requirement, please specify in details what is the exact requirement that you are trying to achieve. Thus, we would be able to think about a suitable solution and assist you further.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
fabrizio
Top achievements
Rank 1
Veteran
answered on 19 May 2017, 12:07 PM

Hello DESS

Your solution is perfect. Thank You very much

Tags
MultiColumn ComboBox
Asked by
Boris
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
fabrizio
Top achievements
Rank 1
Veteran
Share this question
or