DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 10 Jul 2007 18:27:31 +0100,    posted on: microsoft.public.dotnet.languages.vb.controls        back       

Thread Index
  1    DesCF


Check for existing value in Combobox list   
I have a textbox and a combobox on a toolstrip.  The user enters either an  ID in the textbox or selects a name from the combobox.  When the user  selects a name from the combobox the textbox is filled in automatically by  setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is  set to the .Text value in the ID textbox.  All works fine but it is  possible to enter a value in the ID textbox that does not exist in the  combobox.  So I have written a procedure to check for the existence of the  value in the combobox prior to setting the value.  The procedure is shown  below.  My question is: Is it possible to do this without iterating  through the values, i.e. is there a single line of code using something like .Contains that enables me to do the same thing ?


   Private Sub txtCustIDEnter_Leave(ByVal sender As System.Object, ByVal e  As System.EventArgs) Handles txtCustIDEnter.Leave

     Dim strCustID As String = Me.txtCustIDEnter.Text.Trim.ToUpper

     If strCustID.Length <> 0 Then
       For Each drv As DataRowView In Me.cboCustNameSelect.ComboBox.Items
         If drv.Row.Item(0).ToString.ToUpper = strCustID Then
           Me.cboCustNameSelect.ComboBox.SelectedValue = strCustID
           Exit For
         End If
       Next
     End If

   End Sub




-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Date:Tue, 10 Jul 2007 18:27:31 +0100   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us