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

Multi column, multi select using checkboxes?

9 Answers 554 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 07 Aug 2009, 09:44 AM
Hi!

Is it possible to create a multicolumndropdown where the first column contains a checkbox.
The user can then select rows by checking the checkboxes.

Is this possible ?

Regards
Per

9 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 07 Aug 2009, 01:50 PM
Hello Per,

Currently RadMultiColumnComboBox doesn't support this feature. We will consider adding it in a future version of RadControls.

However, you can use our RadDropDownButton control and create a custom menu item that contains RadGridView. Here is a sample:

GridMenuItem item = new GridMenuItem();              
item.Grid.DataSource = table;  
item.Grid.MultiSelect = true;  
item.Grid.Size = new Size(400, 300);  
  
RadDropDownButton button = new RadDropDownButton();  
button.Items.Add(item);  
button.Location = new Point(100, 100);  
this.Controls.Add(button);  
  
public class GridMenuItem : RadMenuItemBase  
{  
    RadGridView grid;  
    RadHostItem hostItem;  
  
    public RadGridView Grid  
    {  
        get  
        {  
            EnsureChildElements();  
            return this.grid;  
        }  
    }  
  
    protected override void CreateChildElements()  
    {  
        grid = new RadGridView();  
        grid.BeginInit();  
        grid.BindingContext = new BindingContext();  
        grid.EndInit();  
        hostItem = new RadHostItem(grid);  
        this.Children.Add(hostItem);  
    }  
  
    protected override SizeF MeasureOverride(SizeF availableSize)  
    {  
        SizeF size = base.MeasureOverride(availableSize);  
        return grid.Size;  
    }  
}   
 

If you need further assistance, please do not hesitate to ask.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Zain
Top achievements
Rank 1
answered on 13 Apr 2012, 12:52 AM
Hi there,
I am using this method and have a check box column for the user to make selections in the grid. The problem I have is that when I try to handle the grid selections in the DropDownClosed event of the DropDownButton, the grid and the data source of the grid (which is an observable collection) doesn't have the new values. However, when I launch the grid again, the values that were previously selected are still there intact.
Can I please get help with being able to read the values of the grid? I have also implemented the INotifyPropertyChanged interface for the Objects in the ObservableCollection that is bound to the grid.
0
Svett
Telerik team
answered on 17 Apr 2012, 03:42 PM
Hi Zain,

Thank you for writing.

I am not able to assist you efficiently with supplied information. I recommend opening a support ticket where you can enclose a sample project which demonstrates your approach. This will help us to understand your scenario in depth, hence, we can locate and isolate what causes this misbehavior.

All the best,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
KawaUser
Top achievements
Rank 2
answered on 09 Feb 2013, 07:39 PM
Hello,

I am trying to accomplish a much similar task.  I can see by the dates on the previous posts that it has been awhile.   Has your initial response changed over the the intervening time or is your suggestion still the best approach?

Respectfully,

Derrick Isaacs
0
Svett
Telerik team
answered on 13 Feb 2013, 05:35 PM
Hello Derrick,

The only way to achieve the desired scenario is by using the suggestion of my colleague Jack.

Do not hesitate to contact us if you need assistance in adopting this scenario on your side.

Regards,
Svett
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
KawaUser
Top achievements
Rank 2
answered on 14 Feb 2013, 01:51 PM
Thought I should submit my final solution:   In my project I had to build an excel addin with several drop downs to allow the user to slice and dice a larger dataset.   One of these (multicolumn dropdown) was a list of available months (2012 Jan, 2012 Feb, etc.) which I wanted the user to be able to select individually.  The currently selected items would be displayed  via a check box next to month decription.  Also included in the first row was a "Select All" option which would turn all of the options on or off if selected, and would be turned on or off to fit the rest of the items selected.  And finally in the controls text box I display a count of the selected items. 

As a datasource I have a datatable with the description (visible), numeric value (hidden) used to sort the list , an bit field (visible) used when selecting or unselecting an item, and a text field (hidden) used to display the summary.  I use the mouse click event to toggle a boolean variable (DD_Open) which is used to decide if the dropdownclosing event should be cancelled or not. When the toggle is to close the combo, disabling and then immediately re-enabling it will force the drop down closed. 

To update the dropdown I assign the underlying grid of the combo box to a a variable and add a handler to its cell click event.  When the event fires, I identify the row the cell is in  and toggle the bit column in the corresponding row of the datatable as well as make any other desired changes and then rebind the datatable to the grid.
'*************************************************************************************************************** 
   
Imports Telerik.WinControls.UI 
Imports System.ComponentModel 
    
Public Class APFilters 
    
    Private DD_Open As Boolean 
    Private CD_TA As RPO2.DataSet1TableAdapters.vwRPO_CustomDtSelTableAdapter 
    Private CustDts As RPO2.DataSet1.vwRPO_CustomDtSelDataTable 
    Private CustDts_Parm As String 
  
 '*************************************************************************************************************** 
     Private Sub APFilters_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
        Try 
            CD_TA = New RPO2.DataSet1TableAdapters.vwRPO_CustomDtSelTableAdapter 
            CustDts = CD_TA.GetData 
            cboRptDates3.ValueMember = "Value" 
            cboRptDates3.DisplayMember = "SelText" 
            cboRptDates3.DataSource = CustDts 
            CustDts_Grid = cboRptDates3.EditorControl 
        Catch 
        End Try 
    
    
    End Sub 
    
'*************************************************************************************************************** 
    Private Sub CustDts_Grid_CellClick(ByVal sender As Object, 
                                       ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) _ 
                                       Handles CustDts_Grid.CellClick 
        Try 
            If e.RowIndex >= 0 AndAlso e.ColumnIndex > 0 AndAlso Not IsNothing(CustDts) Then            'If valid row and column 
    
                Dim CD_Row As RPO2.DataSet1.vwRPO_CustomDtSelRow 
                Dim CheckBoxValue As Boolean = CustDts_Grid.Rows(e.RowIndex).Cells("Selected").Value        'Old Value of check box 
                Dim DataRowIndex As Integer = CustDts_Grid.Rows(e.RowIndex).Cells("Value").Value            'Identify the datatable row affected 
                Dim X As Integer = 0                                                                        'Initialize Counter 
                Dim SelAll As Boolean = True                                                                'Intialize Sel All tracker 
                CustDts_Parm = ";"                                                                          'Initialize Parameter 
    
                If DataRowIndex = 0 Then                                                                'If Select All Option' 
                    For Each CD_Row In CustDts.Rows                                                         'Process All Rows to correspond to the select all row 
                        CD_Row.Selected = Not CheckBoxValue                                                     'Set each row to the toggled value of select all  
                    Next                                                                                    'Next Row 
                Else                                                                                    'Else Not Select All Option 
                    CustDts.FindByValue(DataRowIndex).Selected = Not CheckBoxValue                          'Set the clicked row to its toggled value 
                End If 
    
                For Each CD_Row In CustDts.Rows                                                         'Process All rows skipping the select all row 
                    If CD_Row.Value <> 0 Then 
                        If CD_Row.Selected Then                                                         'If Row is selected 
                            X = X + 1                                                                       'Increment selected count 
                            CustDts_Parm = CustDts_Parm + ";" + CD_Row.Name                               'Add to custom date parameter 
                        Else                                                                            'Else Row is not selected 
                            SelAll = False                                                                  'Turn off select all  
                        End If 
                        CustDts_Parm = (CustDts_Parm + ";").Replace(";;", ";") 
                    End If 
                Next 
    
                For Each CD_Row In CustDts.Rows                                                         'Add # Items selected to each row so which ever row is selected  
                    'it is in the text field of the combobox 
    
                    If Not IsNothing(CD_Row) Then 
                        CD_Row.SelText = X.ToString + " item(s) selected" 
                    End If 
                Next 
    
                CustDts.FindByValue(0).Selected = SelAll                                                'set select all to appropriate value 
                cboRptDates3.DataSource = CustDts                                                       'rebind to datasource 
            End If 
        Catch ex As Exception 
    
        End Try 
        Diagnostics.Debug.Print(CustDts_Parm) 
    End Sub 
  
'*************************************************************************************************************** 
    Private Sub cboRptDates3_DropDownClosing(ByVal sender As System.Object, 
                                             ByVal args As Telerik.WinControls.UI.RadPopupClosingEventArgs) _ 
                                             Handles cboRptDates3.DropDownClosing 
        If DD_Open Then 
            args.Cancel = True 
        End If 
    End Sub 
   
'*************************************************************************************************************** 
    Private Sub cboRptDates3_MouseClick(ByVal sender As Object, _ 
                                        ByVal e As System.Windows.Forms.MouseEventArgs) _ 
                                        Handles cboRptDates3.MouseClick 
        DD_Open = Not (DD_Open) 
    
        If Not (DD_Open) Then 
            cboRptDates3.Enabled = False 
            cboRptDates3.Enabled = True 
        End If 
    
    End Sub 
    
    
End Class
0
Jack
Telerik team
answered on 20 Feb 2013, 09:18 AM
Hi KawaUser,

Thank you for sharing your solution with the community. 

Yes, your code seems to be OK and it will do the job. One drawback is that there is no way to indicate that multiple rows are selected in drop down textbox or in the Value property of RadMultiColumnComboBox. I noted also that you are setting the DataSource property every time when handling the CellClick event. I am not sure why this is necessary in your scenario. This can lead to performance issues.

I translated your solution in C#:

bool shouldCancel = false;
 
void radMultiColumnComboBox1_DropDownClosing(object sender, RadPopupClosingEventArgs args)
{
    if (shouldCancel)
    {
        args.Cancel = true;
        shouldCancel = false;
    }
}
 
void EditorControl_CellClick(object sender, GridViewCellEventArgs e)
{
    GridCheckBoxCellElement cell = sender as GridCheckBoxCellElement;
    if (cell != null)
    {
        shouldCancel = true;
        bool value = cell.Value != null && cell.Value != DBNull.Value ? (bool)cell.Value : false;
        cell.Value = !value;
    }
}

I added also your scenario as a feature request in our issue tracking system and updated your Telerik points. Use the following link to track the issue status.

Do not hesitate to contact us if you have further questions.

All the best,
Jack
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Bradley Lane
Top achievements
Rank 1
answered on 22 Apr 2014, 01:47 PM
I'm looking for similar functionality... I can't find the feature request via the supplied link.

Has this feature progressed?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Apr 2014, 03:25 PM
Hello Bradley,

Thank you for writing.

We have migrated our Public Issue Tracking System to a Feedback PortalYou can track the feature progress, subscribe for status changes and add your vote/comment to it on the following link - Feedback Item

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

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
MultiColumn ComboBox
Asked by
Per
Top achievements
Rank 1
Answers by
Jack
Telerik team
Zain
Top achievements
Rank 1
Svett
Telerik team
KawaUser
Top achievements
Rank 2
Bradley Lane
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or