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

Selecting value in multiColumnCombobox

4 Answers 580 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jarek Rutowicz
Top achievements
Rank 1
Jarek Rutowicz asked on 26 Sep 2009, 01:18 PM
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.

4 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 29 Sep 2009, 11:59 AM
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)  
    {  
        returnfalse;  
    }  
    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();  
            }  
            returntrue;  
        }  
    }  
    returnfalse;  
}  
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.
0
George
Top achievements
Rank 1
answered on 12 Nov 2009, 10:22 AM
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
0
Jack
Telerik team
answered on 12 Nov 2009, 05:18 PM
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.
0
Gustav Mulder
Top achievements
Rank 1
answered on 06 Jan 2010, 08:40 AM
Thanx the selectedvalue change works in Q3
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Jarek Rutowicz
Top achievements
Rank 1
Answers by
Jack
Telerik team
George
Top achievements
Rank 1
Gustav Mulder
Top achievements
Rank 1
Share this question
or