Solved

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

Posted on 2008-10-29
2
728 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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