Hi Rolf,
Thank you for posting.
[quoted text, click to view] >But if I bind Listbox to comp and want to see comp01, comp02, comp03 at
for example DisplayMember in the Designer combox is nothing. So I think the
problem is what to return with IListSource.GetList ?
I am sorry but I don't think you could see comp01, comp02 and omp03 at
DisplayMember in the Properties window no matter what to return with
IListSource.GetList.
IListSource.GetList method returns a collection which implements IList. If
the type of the objects in this collection is definite at design time, VS
will recognize the type and enumerate all its public properties at
DisplayMember in the Properties window.
Here is an example. I set up Windows application and place a ListBox on a
form. I create a component called MyListSource in the project. Below is the
code of MyListSource.
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
class MyListSource:Component,IListSource
{
System.Collections.IList IListSource.GetList()
{
List<Employee> employees = new List<Employee>();
return employees;
}
}
public class Employee
{
private string _id;
private string _name;
private Decimal parkingId;
public string ID
{
get { return _id; }
set { _id = value;}
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public Decimal ParkingID
{
get { return parkingId; }
set { parkingId = value;}
}
}
Compile the project. Drag&drop MyListSource from toolbox onto a form to add
an instance of MyListSource(e.g myListSource1) in the form. Select the
ListBox and set its DataSource property to myListSource1. Then VS will
display ID,Name and ParkingID at DisplayMember in the Properties window.
Could you tell me why you want to show comp1, comp2 and comp3 at
DisplayMember in the Properties window?
Hope it helps.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.