Databind list of dates

M

Matt Lowrance

I have created an object that has a number of properties, that I am
now trying to simply databind to a form. I am using the data designer
to do it and just dragging and dropping the items onto the form.

Everything works great, except one of the items in my object is a list
of dates. Right now I am using a generic list to hold these, but when
I go to put this item on the form it only lists "None" as the type of
control I can use to represent it.

I just want to list the dates in a combobox so the user can select the
correct one. The dates are coming from a backend database earlier in
the process, so at this point they are actual DateTime objects.

Would it be easier to change them to string and use a type of string
list, then just convert them back with CDate() when I need to use
them? What type of string list is bindable?

Thanks in advance for any help.

Matt
 
C

Cor Ligthert[MVP]

Matt,

I cannot get the name, but the most simple sollution with a combobox is to
use a datatable, that goes forever.

\\\
dim dt as new datatable
dim dc as new column("TheDate", System.DateTime)
dt.columns.add(dc)
for each yourdate as datetime in yourlist
dim dr as datarow = dt.rows.newRow
dr.items(dc) = yourdate
dr.rows.Add(dr)
next
yourcombobox.datasource = dt
yourcombobox.valuemember = "TheDate"
yourcombobox.displaymember = "TheDate"
///

Typos or whatever are possible in this because it is typed very quick in
this message.

Cor
 

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

Top