Hello ,
I need to change the selected value in my parent form but the component is in the user controller .
So when I set the value to the multicombobox does not work knowing that the text and selected index take the value well .
Dim page As New RadPageViewPage()
Dim panel As New MyPanel()
strip= TryCast(RadPage1.ViewElement, RadPageViewStripElement)
page.Text = "page" & (strip.Items.Count + 1)
Dim Liste1 As List(Of object)
panel.RadMultiColCmbo1.DisplayMember = "Name"
panel.RadMultiColCmbo1.ValueMember = "PK"
panel.RadMultiColCmbo1.DataSource = Liste1
dim object 1 = myobject
panel.RadMultiColCmbo1.Selectedvalue =myobject.PK
Please help!
Thank you
1 Answer, 1 is accepted
Hello, Jihad,
If I understand you correctly, you have RadMultiColumnComboBox control which you use within a UserControl and you want to set the SelectedValue property to some value in the parent form.
I created a sample project where I created a user control with RadMultiColumnComboBox in order to test this and it seems to work correctly on my end. When I set the SelectedValue property in the main form the value is shown correctly in the multicolumn combo box.
Public Class UserControl1
Public Sub New()
InitializeComponent()
Dim people As List(Of Person) = New List(Of Person)()
For i As Integer = 0 To 50 - 1
people.Add(New Person() With {
.Id = i,
.Name = "Name " & i
})
Next
Me.RadMultiColumnComboBox1.DataSource = people
Me.RadMultiColumnComboBox1.ValueMember = "Id"
Me.RadMultiColumnComboBox1.DisplayMember = "Name"
End Sub
Public ReadOnly Property RadMultiColumnComboBox As RadMultiColumnComboBox
Get
Return Me.RadMultiColumnComboBox1
End Get
End Property
End Class
Public Class Person
Public Property Id As Integer
Public Property Name As String
End Class
' Main Form
Public Class RadForm1
Public Sub New()
InitializeComponent()
Dim control As UserControl1 = New UserControl1()
Me.Controls.Add(control)
control.RadMultiColumnComboBox.SelectedValue = 2
End Sub
End Class
I attached my test project for your reference. Could you please refer to it and let me know how it differs from your set up?
I am looking forward to your reply.
Regards,
Nadya
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Support Team,
I have a C# winforms application using RadMultiColumComboBox (with data populating from another table in SQL Server) and while saving the selected record, the selectedvalue is not getting assigned and when we retrieve the saved record from database, the selectedvalue eveen after assigning multiple times will be null always and the selectedindex also will be -1 always. Please help me to overcome these issues.
this.rmcBrand.SelectedValue = Convert.ToInt32(fkBrand); This code is used to assign also, not working and the selected value is always null.
Below is the method used to assign the saved value from database to the control while loading the saved records.
public static string SetValueMultiColumnCombo(Telerik.WinControls.UI.RadMultiColumnComboBox control, string columnName, string columnValue)
{
DataRow[] drselectedItem = dtTemp.Select($"{columnName } = {columnValue}");if (drselectedItem != null && drselectedItem.Length > 0)
{
int selectedIndex = dtTemp.Rows.IndexOf(drselectedItem[0]);
control.SelectedIndex = selectedIndex; //Getting error from here as selectedindex value is -1 always.
}
}
private void BindBrandMultiColomnComboBox(RadMultiColumnComboBox radMultiColumnComboBox)
{
DataView dvBrand = new DataView(this.dsProduct.Tables["tblBrand"]);
string currentText = radMultiColumnComboBox.Text;
radMultiColumnComboBox.ClearTextOnValidation = false;
//DataRow emptyRow = dvBrand.Table.NewRow();
//emptyRow["PKBrand"] = 0;
//emptyRow["BrandName"] = "";
//emptyRow["TaxCertificates"] = false;
//dvBrand.Table.Rows.InsertAt(emptyRow, 0);
radMultiColumnComboBox.DisplayMember = "BrandName";
radMultiColumnComboBox.ValueMember = "PKBrand";
radMultiColumnComboBox.DataSource = dvBrand;
//set filter
radMultiColumnComboBox.AutoFilter = true;
CompositeFilterDescriptor compositeFilter = new CompositeFilterDescriptor();
FilterDescriptor ftBrand = new FilterDescriptor("BrandName", FilterOperator.Contains, "");
compositeFilter.FilterDescriptors.Add(ftBrand);
//compositeFilter.LogicalOperator = FilterLogicalOperator.Or;
radMultiColumnComboBox.EditorControl.FilterDescriptors.Add(compositeFilter);
((BaseComboBoxElement)radMultiColumnComboBox.MultiColumnComboBoxElement.EditorElement).TextBoxElement.TextBoxItem.TextBoxControl.CharacterCasing = CharacterCasing.Upper;
if (currentText.Length > 0)
{
radMultiColumnComboBox.Text = currentText;
}
}
dvBrand consists of columns PKBrand(Int datatype in SQL), BrandName is varchar type in sql. In RadMultiColumnComboBox column collection also defined with column PKBrand(System.Int32 type) and BrandName (System.String type)
After binding the control with the datasource, displaymember and valuemember, we are calling another method to assign the selectedvalue of the RadMultiColumnComboBox control and the code is given below.
public static string MultiColumnComboSetValue(Telerik.WinControls.UI.RadMultiColumnComboBox control, string columnName, string columnValue) //VW-5635
{
string ErrMsg = "";
if (string.IsNullOrWhiteSpace(columnValue) || columnValue == "-1")//VW-5635
{
control.SelectedIndex = -1;
ErrMsg = "Value Required";
}
else
{
DataTable dtMultiColumnSource = new DataTable();
// dtMultiColumnSource = (DataTable)control.DataSource;
if (control.DataSource != null)
{
if (((DataView)control.DataSource).Count > 0)
{
dtMultiColumnSource = ((DataView)control.DataSource).ToTable();
DataTable dtTemp = new DataTable();
dtTemp = dtMultiColumnSource.Copy();
DataRow[] drselectedItem = dtTemp.Select($"{columnName } = {columnValue}");
if (drselectedItem != null && drselectedItem.Length > 0)
{
int selectedIndex = dtTemp.Rows.IndexOf(drselectedItem[0]);
control.SelectedIndex = selectedIndex;
}
else
{
control.SelectedIndex = -1;
}
}
}
}
return ErrMsg;
}
And we are getting error from this line 'control.SelectedIndex = selectedIndex;' with error message as
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
at Telerik.WinControls.UI.RadMultiColumnComboBoxElement.set_SelectedIndex(Int32 value)
at Telerik.WinControls.UI.RadMultiColumnComboBox.set_SelectedIndex(Int32 value)
at XYZ.Client.ClientHelper.MultiColumnComboSetValue(RadMultiColumnComboBox control, String columnName, String columnValue)
Hello, Justine,
According to the provided information, it seems that the SelectedIndex property is set to an invalid value. In other words, RadMultiColumnComboBox
doesn't contain such a number of rows and a record at such an index doesn't exist. Please correct me if I am wrong. It is not clear what are the available rows in the popup grid and how many records are filtered. Could you please elaborate?
It is important to note that the composite filters allow you to create more complex filtering expressions. This feature is supported for text columns only as the RadMultiColumnComboBox has one common text input for the filtering operation and it is not possible to convert input data to different data formats automatically.
I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem?