How to put only the class name on the combobox?

Asked

Viewed 70 times

1

When adding an object to a combobox and checking it, the full name of the class appears according to Microsoft conventions: NomeDaEmpresa.NomeDoProjeto.ModuloDoSistema.

How do I make only the class name appear?

1 answer

2

By default is presented what is returned by the method ToString() which, if not overwritten, returns the full name(the Qualified name) class .

Overwrite the method ToString(), of the class you are entering into Combobox, so that you return only its name:

public class Myclass
{
    .....
    .....
    public override string ToString() => GetType().Name;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.