Solved

VB 2005 Combobox TextChanged Event.  Distinguish between programmatic modification or user interaction.

Posted on 2008-10-29
2
719 Views
Last Modified: 2012-05-05
I'm populating a combobox in vb 2005 like this.  This line in the code is calling the TextChanged event.
cmbfiletypecode.Text = dr("filetypecode").ToString.Trim

When a user changes one of the values in the combo box it calls the same event.  How can I isolate whether the user has changed a value or it's been changed programatically?



        dt4.Clear()
        cCmd.CommandText = "Select distinct FileTypecode from FileType where FileTypecode is not null order by FileTypecode"
        adapter.SelectCommand = cCmd
        adapter.Fill(dt4)
        cmbFileTypeCode.DisplayMember = "FileTypecode"
        cmbFileTypeCode.ValueMember = "FileTypecode"
        cmbFileTypeCode.DataSource = dt4
        dt4a.Clear()
        cCmd.CommandText = "Select FileNamecode,filetypecode from FileCoverage where FileNamecode = '" & FileNameCode & "'"
        adapter.Fill(dt4a)
        If dt4a.Rows.Count > 0 Then
            For Each dr In dt4a.Rows
                If dr("FileNamecode") = FileNameCode Then
                    cmbfiletypecode.Text = dr("filetypecode").ToString.Trim
                End If
            Next
        Else
            'cmbFileTypeCode.Text = ""
            cmbFileTypeCode.Text = Form1.Grid1(5, i).Value
        End If
0
Comment
Question by:AlHal2
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 22834265
One solution would be to use a flag which you can check in the TextChanged() Event:

Public Class Form1
 

    Private MyChange As Boolean = False
 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        MyChange = True

        cmbfiletypecode.Text = "something"

    End Sub
 

    Private Sub cmbfiletypecode_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbfiletypecode.TextChanged

        If Not MyChange Then

            MessageBox.Show("TextChanged")

        Else

            MyChange = False

        End If

    End Sub
 

End Class

Open in new window

0
 

Author Closing Comment

by:AlHal2
ID: 31511291
Thanks.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now