Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2003, 06:37 AM
Registered User
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combobox SelectedValueChanged Event


I have a pretty straightforward combobox on a form.
During initialization, I set the databindings on the
combobox (DropDownList):

    cboType.ValueMember = "ID"
    cboType.DisplayMember = "Description"
    cboType.DataSource = dsRel.Tables(TBL_RLT)
    cboType.DataBindings.Add(New Binding("SelectedValue",
dsRel, TBL_REL & ".Type"))

Everyting looks as expected, even the proper DisplayValue
is shown. However there are two thing bugging me:

1) The cboType.SelectedValueChanged event is NOT fired
after the DataBindings.Add statement.
2) The cboType.SelectedValue is NOT CORRECT !!

Only after I click on the combobox manually, the proper
event is fired and the cboType.Selected value is correct.

Now, am I doing something wrong or is this a
(undiscovered) bug?



.



 
Old July 18th, 2003, 08:31 AM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the code I use that seems to fire the event.

cboType.ValueMember = "ID"
cboType.DisplayMember = "Description"
cboType.DataSource = dsRel.Tables(TBL_RLT)
cboType.SelectedValue = myObject.Type

I hope this helps,

David
 
Old March 12th, 2005, 07:28 PM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Did you debug your code? I think that SelectedValueChanged event may be triggered but perhaps the value comes as Nothing

I used the following code...

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SqlConnection1.Open()
        SqlDataAdapter1.Fill(DataSet11)

        ComboBox1.ValueMember = "category_no"
        ComboBox1.DisplayMember = "category_desc"
        ComboBox1.DataSource = DataSet11.Tables(0).DefaultView


    End Sub

    Private Sub ComboBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
        Label1.Text = ComboBox1.SelectedValue
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Label1.Text = ComboBox1.SelectedValue
    End Sub


Eralper
http://www.kodyaz.com


Eralper
http://www.kodyaz.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
SelectedValueChanged event is giving me a headache SQLScott Pro Visual Basic 2005 1 January 2nd, 2008 06:46 PM
Event - Sender & Event args dash dev C# 2005 9 December 9th, 2007 07:24 AM
Change of event using 2 combobox yogeshyl Excel VBA 0 July 31st, 2007 05:02 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
About Button event and Keydown event zhangxujun1981 XSLT 1 March 6th, 2004 04:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.