Ejemplo n.º 1
0
    public Form1()
    {
        var companies = new CompanyInfo[]
        {
            new CompanyInfo {
                Name = "Ajax - 1200"
            },
            new CompanyInfo {
                Name = "Bermuda Corp - 1"
            },
            new CompanyInfo {
                Name = "Capitol Inc"
            },
            new CompanyInfo {
                Name = "Dash LLC - "
            },
        };

        Controls.Add(new ComboBox
        {
            Location      = new Point(10, 10),
            DropDownStyle = ComboBoxStyle.DropDownList,

            DataSource    = companies.Select(c => new { FormattedName = RemoveTrailingDash(c.Name) }).ToList(),
            DisplayMember = "FormattedName",
        });
    }