How to put only the class name in comboBox?

1

When adding an object in a comboBox and checking it, the full name of the class is displayed according to Microsoft conventions: NomeDaEmpresa.NomeDoProjeto.ModuloDoSistema .

How do I make only the class name appear?

    
asked by anonymous 11.06.2017 / 08:38

1 answer

2

By default, this is returned by the ToString() method, which, if not overridden, returns the distinguished name of the class.

Override the ToString() method, of the class you are inserting into the ComboBox, to return only the name of it:

public class Myclass
{
    .....
    .....
    public override string ToString() => GetType().Name;
}
    
11.06.2017 / 13:45