7 Answers, 1 is accepted
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 15 Mar 2011, 10:12 AM
Hello Raj,
To do this you will need to provide a datasource that you can use as a Display and Value member. The RadListDataItem simply has a text property that is used for both. So, using a datasource exmaple would be as follows
Hope that helps
Richard
To do this you will need to provide a datasource that you can use as a Display and Value member. The RadListDataItem simply has a text property that is used for both. So, using a datasource exmaple would be as follows
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private BindingList<Person> people = new BindingList<Person>(); private void Form1_Load(object sender, EventArgs e) { people.Add(new Person("Richard", 1)); people.Add(new Person("Bob", 2)); this.radDropDownList1.DataSource = people; this.radDropDownList1.DisplayMember = "Name"; this.radDropDownList1.ValueMember = "Id"; } } public class Person { public Person(string name, int id) { this.Name = name; this.Id = id; } public string Name {get; set;} public int Id {get; set;} }Hope that helps
Richard
0
Mohan
Top achievements
Rank 1
answered on 15 Mar 2011, 07:24 PM
Hi Richard,
Thanks for the reply, Is it possible you can send me the code in VB.Net please.
Thank you,
Raj
Thanks for the reply, Is it possible you can send me the code in VB.Net please.
Thank you,
Raj
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 15 Mar 2011, 10:25 PM
Hi Raj,
Here is the code in VB.NET
For reference, you might be interested to know about the Telerik Code Converter which can convert to and from C#/vb.net
Hope that helps. Please remember to mark as answer and if you have further questions, then please let me know
Thanks
Richard
Here is the code in VB.NET
Public Partial Class Form1 Inherits Form Public Sub New() InitializeComponent() End Sub Private people As New BindingList(Of Person)() Private Sub Form1_Load(sender As Object, e As EventArgs) people.Add(New Person("Richard", 1)) people.Add(New Person("Bob", 2)) Me.radDropDownList1.DataSource = people Me.radDropDownList1.DisplayMember = "Name" Me.radDropDownList1.ValueMember = "Id" End SubEnd ClassPublic Class Person Public Sub New(name As String, id As Integer) Me.Name = name Me.Id = id End Sub Public Property Name() As String Get Return m_Name End Get Set m_Name = Value End Set End Property Private m_Name As String Public Property Id() As Integer Get Return m_Id End Get Set m_Id = Value End Set End Property Private m_Id As IntegerEnd ClassFor reference, you might be interested to know about the Telerik Code Converter which can convert to and from C#/vb.net
Hope that helps. Please remember to mark as answer and if you have further questions, then please let me know
Thanks
Richard
0
Daniel
Top achievements
Rank 1
answered on 30 Mar 2011, 08:31 PM
Why can't I use
When I try to use IList, raddropdownlist display the name of my class, following the example, it would be "Person" display several times.
Could you help me to understand why?
Thanks.
Best Regards.
IList instead ofBindingList ? When I try to use IList, raddropdownlist display the name of my class, following the example, it would be "Person" display several times.
Could you help me to understand why?
Thanks.
Best Regards.
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 12:18 PM
Hello,
You can use List instead of BindingList. If you take the first exmaple in this thread and replace BindingList with List, then it also works without issue. If you need further help, please let me know.
Thanks
Richard
You can use List instead of BindingList. If you take the first exmaple in this thread and replace BindingList with List, then it also works without issue. If you need further help, please let me know.
Thanks
Richard
0
Hi Daniel,
Thank you for writing.
Please refer to the beginning of this help article, where you can find the answer to your question. If you need additional information, you might find this MSDN article helpful.
I hope this helps.
All the best,
Stefan
the Telerik team
Thank you for writing.
Please refer to the beginning of this help article, where you can find the answer to your question. If you need additional information, you might find this MSDN article helpful.
I hope this helps.
All the best,
Stefan
the Telerik team
0
clint
Top achievements
Rank 1
answered on 31 Oct 2014, 06:19 AM
You can use a Dictionary Object and solev this issue..
Dictionary comboSource = new Dictionary();
comboSource.Add("1", "Sunday");
comboSource.Add("2", "Monday");
comboBox1.DataSource = new BindingSource(comboSource, null);
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
Full Source:
http://net-informations.com/q/faq/combovalue.html
Clint
Dictionary comboSource = new Dictionary();
comboSource.Add("1", "Sunday");
comboSource.Add("2", "Monday");
comboBox1.DataSource = new BindingSource(comboSource, null);
comboBox1.DisplayMember = "Value";
comboBox1.ValueMember = "Key";
Full Source:
http://net-informations.com/q/faq/combovalue.html
Clint
