Results 1 to 3 of 3

Thread: [02/03] Default processing in form load event

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    4

    [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:
    1. Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         datranstype.Fill(uscData.DsPersonalFinance.TransType)
    3.      
    4.  cboTransType.DataSource = uscData.DsPersonalFinance
    5.         cboTransType.DisplayMember = "TransType.transType"
    6.         cboTransType.ValueMember = "TransType.transTypePK"
    7. 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.
    Last edited by Sodapop; Mar 31st, 2006 at 04:09 PM.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    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:
    1. cboTransType.DisplayMember = "TransType.transType"
    2.         cboTransType.ValueMember = "TransType.transTypePK"
    3.         cboTransType.DataSource = uscData.DsPersonalFinance
    Regards,

    - Aaron.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    4

    Re: [02/03] Default processing in form load event

    Thanks Aaron, that worked and it fixed my problem.
    Visual Studio .NET 2003/.NET Framework 1.1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width