Databinding to ToolStripCombobox fails

T

twq

Hello

I have a form with a menustrip, containing a Combobox.

on the load event, i load Data into _dates (Datatable) which is
afterwards bound in the DropDownOpened Event of the menu,

class field:
Private _dates As DataTable


frm load Event:
Private Sub frmPerfoOverview_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

'Database.GetData returns a Datatable for a given SQL.

_dates = Database.GetData("SELECT DISTINCT VALUATION_DATE FROM
USERTABLE_PBENH_PERF ORDER BY VALUATION_DATE DESC")
End Sub


DropDownOpened Event:

Private Sub ValuationDateToolStripMenuItem_DropDownOpened(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
ValuationDateToolStripMenuItem.DropDownOpened

Dim bnd As New Binding("Text", _dates, "VALUATION_DATE", True)
bnd.FormatString = "dd/MM/yyyy"
Me.ToolStripComboBox1.ComboBox.DataBindings.Clear()
Me.ToolStripComboBox1.ComboBox.DataBindings.Add(bnd)
Me.ToolStripComboBox1.ComboBox.BindingContext =
Me.BindingContext
Me.ToolStripComboBox1.ComboBox.DataSource = _dates
Me.ToolStripComboBox1.ComboBox.DisplayMember =
"USERTABLE_PBENH_PERF.VALUATION_DATE"
Me.ToolStripComboBox1.ComboBox.ValueMember =
"USERTABLE_PBENH_PERF.VALUATION_DATE"
End Sub


My problem is that the datatable that i am binding contains like 5-6
different dates but only the first one is shown in the combobox, and
it appears that only the first one is actually loaded in the combobox
since i dropdown combo is empty ??

Can anyone help me with that ?
Vb 05

Thank you very much
Best regards
tobi
 

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