Multipart DataSource Display Members

  • Thread starter Thread starter Wingot
  • Start date Start date
W

Wingot

Hey,

I've got a combobox that is bound to a datasource for a customer. What I want
to do is set the Display Member to the multipart value "Surname, FirstName",
but as far as I can tell only a single one of these is possible.

How would I go about doing this?

Regards,
Wingot
 
Wingot,

You are going to have to create a new type to do this. Basically, the
new type would have a reference to the item that you want to bind to, and
exposes a property which will create the composite display that you want to
achieve.

If you were using WPF, you could create a custom data template for your
type, and easily show both values in the order you want without resorting to
a new type.
 
Nicholas has covered the "facade" approach. Of course, at the simplest
level you could just add a new property to the main class to provide
this formatted info.

If neither of these suit, then there is a third option involving
custom type-descriptors and type-description-providers, to create
additional pseudo-properties (at run-time). It isn't trivial, but if
the scenario *demands* it I can provide more info.

But I don't recommend it unless you really need it; it is a bit beyond
the norm...

Marc
 
Hey,

I know that this is probably a really newb question, but how do I create a new
type?


Nicholas Paldino said:
Wingot,se You are going to have to create a new type to do this.
Basically, the 3new type would have a reference to the item that you want to
bind to, and -exposes a property which will create the composite display that
you want to 4achieve.Z2 If you were using WPF, you could create a custom
data template for your utype, and easily show both values in the order you
want without resorting to ba new type.UVZ-- d - Nicholas Paldino
[.NET/C# MVP]4 - (e-mail address removed)@b"Wingot"
<news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top