[02/03] Default processing in form load event
In a combobox i have filled with data the "selectedindexChanged" event fires on form load.
VB Code:
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
datranstype.Fill(uscData.DsPersonalFinance.TransType)
cboTransType.DataSource = uscData.DsPersonalFinance
cboTransType.DisplayMember = "TransType.transType"
cboTransType.ValueMember = "TransType.transTypePK"
End Sub
Is there a reason for the selectedIndexChanged on that event to fire on form load? and is there a way to stop that event from firing, it is causing some problems.
Re: [02/03] Default processing in form load event
Setting the DataSource property triggers the SelectedIndexChanged event before you've set your ValueMember property.
Simply set the DataSource afterwards and you won't get an unexpected SelectedValue type
VB Code:
cboTransType.DisplayMember = "TransType.transType"
cboTransType.ValueMember = "TransType.transTypePK"
cboTransType.DataSource = uscData.DsPersonalFinance
Regards,
- Aaron.
Re: [02/03] Default processing in form load event
Thanks Aaron, that worked and it fixed my problem.