Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics 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 5th, 2007, 10:53 AM
Authorized User
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default Filling a combo box w/in datagridview

The horrible part is ... I had this working!
Then I found a problem with the underlying table, fixed it, and it hasn't worked correctly since ...

What I want to do:
W/in a data grid view, build a list of carriers and show the available networks as a combo box.
If the carrier already exists, its' current network should show as the current value in the combo box.

What I have right now:
The list of carriers and a blank in the combo box.
The combo box is filled with the available networks.
If I select a network, as soon as I go to the next row in the view, the box is blank again.

This is the code I'm currently using:
    Private Sub frmCarrier_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles MyBase.Load



    End Sub
    Private Sub LoadNetworkLookup()
        'using runtime DataSet and DataAdapters to load combo box
        Me.Cursor = Cursors.WaitCursor
        Dim strSQL As String = _
            "SELECT NetworkID, NetworkTypeName from Network;"

        ' connect to SQL Server
        Dim strConn As New SqlConnection(APC_WirelessConnectionString)

        Dim daNetwork As New SqlDataAdapter
        Dim cmdNetwork As New SqlCommand(strSQL, strConn)
        Dim dsNetwork As New DataSet
        Dim dvNetwork As New DataView

        cmdNetwork.CommandType = CommandType.Text
        daNetwork.SelectCommand = cmdNetwork

        'Try Catch Block for error checking

            dvNetwork = dsNetwork.Tables(0).DefaultView

            With Me.dgv_cmbNetwork
                .DataSource = dvNetwork
                .DisplayMember = "NetworkTypeName"
                .ValueMember = "NetworkID"
            End With
        Catch ex As Exception
        End Try

        Me.Cursor = Cursors.Default
    End Sub
Does any one have a clue what I broke? And better yet, how I can fix it?


Old July 12th, 2007, 07:26 AM
Friend of Wrox
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india

try to make DataSet and DataView Module level variables and then check

Similar Threads
Thread Thread Starter Forum Replies Last Post
Locking a Combo Box - Sync with DataGridView hollertrek General .NET 0 March 24th, 2008 09:59 AM
Multi-column combo box in datagridview aad1 C# 0 June 5th, 2006 09:58 AM
adding my own combo box in datagridview drachx Pro Visual Basic 2005 0 January 27th, 2006 03:04 AM
filling a combo box from a data object allee_man Beginning VB 6 1 March 1st, 2005 08:08 AM
filling a combo box using an array tware VB Databases Basics 0 September 21st, 2004 08:40 AM

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