Database
  Home arrow Database arrow Page 5 - Working With ADOX and Combo Box Control
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Working With ADOX and Combo Box Control
By: Mohammed Qattan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2004-09-21

    Table of Contents:
  • Working With ADOX and Combo Box Control
  • Code
  • Using Combo Box Control
  • Employee Form
  • More on Combo Box

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working With ADOX and Combo Box Control - More on Combo Box


    (Page 5 of 5 )

    We checked if the Combo Box had some items, and we checked the Count of the items. Since we have more than the zero items, then we will ask the Combo Box to select the first item, and we specify that the SelectedIndex should be to the first item (Zero based)

    Very true, that should not be it, when the user selects an employee from the Combo Box, then we need to display the employee information such as the name and the salary.

    Mind you that we bound the control to a collection of employees.

    Couldn’t be more clever -- what we have in the “Items” property of the “cboEmployees” is nothing but a collection of “Employee” object.

    So let's get into the “cboEmployees_SelectedIndexChanged” to get a better understanding of what we are talking about.

    Private Sub cboEmployees_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

    cboEmployees.SelectedIndexChanged
            Dim oEmployee As Employee
            Try
                'Get the item that was selected in the combo box so

    that we can load
                'the textboxes with information from the Employee that

    was selected
                If cboEmployees.SelectedIndex > -1 Then
                    oEmployee = cboEmployees.SelectedItem
                    txtName.Text = oEmployee.Name
                    txtSalary.Text = oEmployee.Salary

                End If
            Catch oException As Exception
                'Handle the Exception here
                MessageBox.Show(oException.ToString)
            End Try
        End Sub

    1) First we need to check that the Combo Box has items.

    2) If true, then we can set the selected item to the oEmployee Object, (remember that the items of the cboEmployees are nothing but a collection of Employee?)

    3) Since we have a valid Employee object, then we can use its properties such as the “Name” and the “Salary”.

    That was a quick implementation on how to use the new .Net Combo Box. It is so efficient specially when working between tiers. And we also hold to the Collections design pattern, and the object oriented concepts.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    DATABASE ARTICLES

    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT