CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Combo Box

  1. #1
    Join Date
    Nov 2003
    Posts
    47

    Combo Box

    Hello to all
    I am working on an inventory system with Sql server and VB.net
    I enter the Items Like pencil, pen, notepad in Items names and they get saved in the database..

    Now i am using anyother form where in the combo box these items should be shown....

    I wana to fill the list of items like pencil, pen in the combo Boxx
    How will i implemet this in my code using sql server....


    q.Add("Item_Date", cmbDatepurchase.Value.ToString())
    q.Add("Item_RecepitNo", txtRecpno.Text.ToString())
    q.Add("Item_OrderNo", txtOrderno1.Text.ToString())
    q.Add("Item_id", cmbItemid.Value.ToString())

    q.Add("Item_Des1", txtDescriptionitem.Text.ToString())
    q.Add("Item_Quantity", txtQuantityitem.Text.ToString())
    q.Add("Item_Price", txtPriceitem.Text.ToString())
    q.Add("Item_ReceivedBy", cmbRecvby1.Text.ToString())

    Dim SQL As String = SQL_Methods.SqlQuery_Insert("tblItems", q)
    oConnect.ExecUpdate(SQL)
    MessageBox.Show("Item saved")

    This it the code
    when i select the Item cobmo box all items should be shown.. what will be the code

    How I will make use of combo BOx... Plz anyone help me in this regard
    faiza

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Combo Box

    Quote Originally Posted by faiza046
    when i select the Item cobmo box all items should be shown.. what will be the code

    How I will make use of combo BOx... Plz anyone help me in this regard
    If I understand you correctly, you want to know how to use the combobox ¿

    You could perhaps look at the SelectedIndexChanged event

  3. #3
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: Combo Box

    I don't understand what the relevance of the code you have posted to the ComboBox issue is.
    A combobox can be filled with data from a DataTable:
    Code:
    MyComboBox.DataSource = yourDataTableObject
    MyComboBox.DisplayMember = "Name" 'The name of the column with the text to show
    MyComboBox.ValueMember = "ID" 'The name of the column with the value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured