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

Set Selection based on initial value from database

4 Answers 120 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 26 Oct 2016, 11:58 AM

After I load my MultiColumnCombobox using a dataset. How do I set the value after a record is pulled from the database? I want to use Column(0)

Column(0) = ID

Column(1) = Desc

 

 

Initial Load:   mcboApCashTerms.DataSource = dsTerms.Tables(0)

User pulls record from database: rec.CashTermId = "24"

How to do go to the row where Column(0) = "24" ?

 

 

4 Answers, 1 is accepted

Sort by
0
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
answered on 26 Oct 2016, 12:29 PM

I found a way of finding the value using a loop, but is there a more efficient method?

1.For x As Integer = 0 To mcboApCashTerms.EditorControl.Rows.Count - 1
2.    If mcboApCashTerms.EditorControl.Rows(x).Cells(0).Value = TermCD Then
3.        mcboApCashTerms.SelectedIndex = mcboApCashTerms.EditorControl.Rows(x).Index
4.        Exit For
5.    End If
6.Next
0
Accepted
Hristo
Telerik team
answered on 26 Oct 2016, 12:54 PM
Hi Bob,

Thank you for writing.

The approach you shared is valid. Alternatively and depending on your actual scenario you can also perform a query against your data source object and directly set the returned index as selected to your RadMultiColumnCombobox control.

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
answered on 26 Oct 2016, 01:01 PM

Thanks for confirming, Hristo!

I'm interested in using the dataset, but haven't used this method before. If it isn't too much trouble. what would that look like? Otherwise, I'll do some Internet browsing.

 

 

0
Hristo
Telerik team
answered on 27 Oct 2016, 12:30 PM
Hi Bob,

Thank you for writing back.

I see that you are using a data table so you can check the following threads discussing a similar matter: 
I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
 
Tags
MultiColumn ComboBox
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Hristo
Telerik team
Share this question
or