Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. combobox Problem....

combobox Problem....

Scheduled Pinned Locked Moved Visual Basic
helptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soniasan
    wrote on last edited by
    #1

    I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem

    C S 2 Replies Last reply
    0
    • S soniasan

      I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      soniasan wrote:

      Please tell me how to solve this System.Data.DatarowView. Problem

      This means you have not set the ValueMember of the combobox, so it's showing the ToString of the object referred to

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • S soniasan

        I am working in window based application funFillCombo_prod(CmbProduct, "select productid,product from product_master where status=1") CmbProduct.ValueMember = "productid" CmbProduct.DisplayMember = "product" CmbProduct.SelectedIndex = 0 In function I fill the combobox ……… by dataset Public Function funFillCombo_prod(ByVal cmbCombo As ComboBox, ByVal strsql As String) As Boolean Try Dim intI As Integer If con.State <> ConnectionState.Open Then con.Open() GDataAdapter = New SqlDataAdapter(strsql, con) GDataSet = New DataSet() GDataAdapter.Fill(GDataTable) cmbCombo.DataSource = GDataTable.DefaultView funFillCombo_prod = True Catch ex As Exception MsgBox(Err.Source & " : " & Err.Description, vbInformation, g_MSG_Title) funFillCombo_prod = False Finally GDataSet = Nothing End Try Exit Function End Function Private Sub CmbProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbProduct.SelectedIndexChanged If CmbProduct.Items.Count > 0 Then If CmbProduct.SelectedIndex <> -1 Then MessageBox.Show(CmbProduct.SelectedValue.ToString()) End If End If End Sub Problem is that in CmbProduct_SelectedIndexChanged I want valumember of a combobox But msgbox which I write in that event is giving me the desired o/p but problem is that… For two times I got this message System.Data.DatarowView. then I got the valuemember which I require, Please tell me how to solve this System.Data.DatarowView. Problem

        S Offline
        S Offline
        SamRST
        wrote on last edited by
        #3

        Set the Datamember and valuemember property of the combobox.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups