Selecting value in multiColumnCombobox

5 posts, 0 answers
  1. Jarek Rutowicz
    Jarek Rutowicz avatar
    7 posts
    Member since:
    Aug 2009

    Posted 26 Sep 2009 Link to this post

    I hava a problem with selecting value in RadColumnComboBox.I can't even change property selectedValue.

    this.radMultiColumnComboBoxMachineEventWorkerApproved.DataSource = this.bindingSourceWorkers; 
    this.radMultiColumnComboBoxMachineEventWorkerApproved.ValueMember = "idWorker"
    this.radMultiColumnComboBoxMachineEventWorkerApproved.DisplayMember = "surname"
     
                foreach (var column in this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns) 
                { 
                    column.IsVisible = false
                } 
     
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["idWorker"].IsVisible = true
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["name"].IsVisible = true
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["surname"].IsVisible = true
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["PESEL"].IsVisible = true
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["name"].HeaderText = "Imię"
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["surname"].HeaderText = "Nazwisko"
                this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.Columns["PESEL"].HeaderText = "Pesel"
     
    // ------------ now I try to change value 
     
    this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.SelectedValue = 5; 
    var selectedValue = this.radMultiColumnComboBoxMachineEventWorkerApproved.MultiColumnComboBoxElement.SelectedValue; 

    After running this code selectedValue is 1 not 5. A can't find a way to choose element in multicolumnbox programicaly so the user could see selected item before changing value to other.

    Jarek.
  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 29 Sep 2009 Link to this post

    Hi Jarek,

    I confirm that there is an issue with SelectedValue property in RadMultiColumnComboBox. I added the issue in our bug tracking system and it will be addressed in our upcoming releases. I updated your Telerik points for this issue report.

    You can use the following function to work around the issue:

    RadMultiColumnComboBoxSelectValue(comboBox, 5);  
    //...  
    bool RadMultiColumnComboBoxSelectValue(RadMultiColumnComboBox comboBox, object valueToSelect)  
    {  
        if (comboBox == null || valueToSelect == null)  
        {  
            return false;  
        }  
        foreach (GridViewDataRowInfo row in comboBox.EditorControl.Rows)  
        {  
            object value = row.Cells[comboBox.ValueMember].Value;  
            if (value != null && value.Equals(valueToSelect))  
            {  
                comboBox.EditorControl.CurrentRow = row;  
                object displayValue = row.Cells[comboBox.DisplayMember].Value;  
                if (displayValue != null)  
                {  
                    comboBox.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.Text = displayValue.ToString();  
                }  
                return true;  
            }  
        }  
        return false;  
    }  

    I hope this helps. If you have more questions, just write us back.

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. George
    George avatar
    62 posts
    Member since:
    Sep 2008

    Posted 12 Nov 2009 Link to this post

    Facing similar problem here while upgrading to Q3 from Q1 version. My project is now in chaos... as I use moumerous combo and list boxes all over my project, and trying to ammend code as you have suggested is a nightmare. With all due respect, this is a major "bug" and it needs to be addressed now, not at some time in your later releases. Furthermore, the Q3 version fixes a "bug" with form borders which displayed very thin, and made it very hard or almost impossible for the end user to grip a form border to resize a form. So, sticking to Q3 is imperative because my clients have raised hevoc over the form border issue. Having said that I would greatly appreciate a response on your part when the selectedvalue event will function properly and as intended.

    Regards,

    George
  5. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 12 Nov 2009 Link to this post

    Hello George,

    I understand your concerns. We will do our best to address this issue in our upcoming service pack.

    I would suggest using a custom combobox class that inherits RadMultiColumnComboBox and overrides its SelectedValue property. Here is the code:

    public class CustomMultiColumnComboBox : RadMultiColumnComboBox
    {
        public new object SelectedValue
        {
            get { return base.SelectedValue; }
            set
            {
                RadMultiColumnComboBoxSelectValue(this, value);
            }
        }
     
        bool RadMultiColumnComboBoxSelectValue(RadMultiColumnComboBox comboBox, object valueToSelect)
        {
            if (comboBox == null || valueToSelect == null)
            {
                return false;
            }
            foreach (GridViewDataRowInfo row in comboBox.EditorControl.Rows)
            {
                object value = row.Cells[comboBox.ValueMember].Value;
                if (value != null && value.Equals(valueToSelect))
                {
                    comboBox.EditorControl.CurrentRow = row;
                    object displayValue = row.Cells[comboBox.DisplayMember].Value;
                    if (displayValue != null)
                    {
                        comboBox.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.Text = displayValue.ToString();
                    }
                    return true;
                }
            }
            return false;
        }
    }

    Should you have any questions, don't hesitate to ask.

    Kind regards,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Gustav Mulder
    Gustav Mulder avatar
    5 posts
    Member since:
    Jul 2009

    Posted 06 Jan 2010 Link to this post

    Thanx the selectedvalue change works in Q3
Back to Top
UI for WinForms is Visual Studio 2017 Ready