Combobox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    Combobox

    Hi
    I'm using this code to display the selected item in msgbox
    Dim ob As Object
    ob = cmbCategory.Sel ectedItem
    MsgBox(ob.ToStr ing())
    but all what I see is "System.Data.Da taRowView", and the same result with
    cmbCategory.Tex t .

    thanks

    --
    Regads,
    Rochdi
  • Mike

    #2
    RE: Combobox

    Oh, I forget the mention that the code is the
    ComboBox1_Selec tedIndexChanged event
    --
    Regads,
    Rochdi


    "Mike" wrote:
    [color=blue]
    > Hi
    > I'm using this code to display the selected item in msgbox
    > Dim ob As Object
    > ob = cmbCategory.Sel ectedItem
    > MsgBox(ob.ToStr ing())
    > but all what I see is "System.Data.Da taRowView", and the same result with
    > cmbCategory.Tex t .
    >
    > thanks
    >
    > --
    > Regads,
    > Rochdi[/color]

    Comment

    • Phil G.

      #3
      Re: Combobox

      Try

      MsgBox (ComboBox1.Item s(ComboBox1.Sel ectedIndex).ToS tring)

      HTH, Phil

      "Mike" <Mike@discussio ns.microsoft.co m> wrote in message
      news:4D55F397-1F2A-4A7B-81A5-CEC98E38A830@mi crosoft.com...[color=blue]
      > Hi
      > I'm using this code to display the selected item in msgbox
      > Dim ob As Object
      > ob = cmbCategory.Sel ectedItem
      > MsgBox(ob.ToStr ing())
      > but all what I see is "System.Data.Da taRowView", and the same result with
      > cmbCategory.Tex t .
      >
      > thanks
      >
      > --
      > Regads,
      > Rochdi[/color]


      Comment

      • Dennis

        #4
        RE: Combobox

        Your objects in the combo box are of type "System.Data.Da taRowView" whose
        "ToString" method returns the object's type name. Also, the text placed
        into the combo items will be whatever the object's "ToString" method returns
        unless you are using binding. I believe that if you are binding the combo
        box to a DataView object, you need to set the ValueMember and DisplayMember
        properties of the combo box.


        Dennis in Houston


        "Mike" wrote:
        [color=blue]
        > Oh, I forget the mention that the code is the
        > ComboBox1_Selec tedIndexChanged event
        > --
        > Regads,
        > Rochdi
        >
        >
        > "Mike" wrote:
        >[color=green]
        > > Hi
        > > I'm using this code to display the selected item in msgbox
        > > Dim ob As Object
        > > ob = cmbCategory.Sel ectedItem
        > > MsgBox(ob.ToStr ing())
        > > but all what I see is "System.Data.Da taRowView", and the same result with
        > > cmbCategory.Tex t .
        > >
        > > thanks
        > >
        > > --
        > > Regads,
        > > Rochdi[/color][/color]

        Comment

        • Mike

          #5
          RE: Combobox

          Yes I'm binding it to a dataset like this:
          cmbCategory.Dat aSource = Qds.Tables(0)
          cmbCategory.Dis playMember = "Category"
          where Category is the column that exist in the Qds.Table(0).
          but how can I set the ValueMember!!!?

          --
          Regads,
          Rochdi


          "Dennis" wrote:
          [color=blue]
          > Your objects in the combo box are of type "System.Data.Da taRowView" whose
          > "ToString" method returns the object's type name. Also, the text placed
          > into the combo items will be whatever the object's "ToString" method returns
          > unless you are using binding. I believe that if you are binding the combo
          > box to a DataView object, you need to set the ValueMember and DisplayMember
          > properties of the combo box.
          >
          >
          > Dennis in Houston
          >
          >
          > "Mike" wrote:
          >[color=green]
          > > Oh, I forget the mention that the code is the
          > > ComboBox1_Selec tedIndexChanged event
          > > --
          > > Regads,
          > > Rochdi
          > >
          > >
          > > "Mike" wrote:
          > >[color=darkred]
          > > > Hi
          > > > I'm using this code to display the selected item in msgbox
          > > > Dim ob As Object
          > > > ob = cmbCategory.Sel ectedItem
          > > > MsgBox(ob.ToStr ing())
          > > > but all what I see is "System.Data.Da taRowView", and the same result with
          > > > cmbCategory.Tex t .
          > > >
          > > > thanks
          > > >
          > > > --
          > > > Regads,
          > > > Rochdi[/color][/color][/color]

          Comment

          • Mike

            #6
            Re: Combobox

            No, it's not working
            --
            Regads,
            Rochdi


            "Phil G." wrote:
            [color=blue]
            > Try
            >
            > MsgBox (ComboBox1.Item s(ComboBox1.Sel ectedIndex).ToS tring)
            >
            > HTH, Phil
            >
            > "Mike" <Mike@discussio ns.microsoft.co m> wrote in message
            > news:4D55F397-1F2A-4A7B-81A5-CEC98E38A830@mi crosoft.com...[color=green]
            > > Hi
            > > I'm using this code to display the selected item in msgbox
            > > Dim ob As Object
            > > ob = cmbCategory.Sel ectedItem
            > > MsgBox(ob.ToStr ing())
            > > but all what I see is "System.Data.Da taRowView", and the same result with
            > > cmbCategory.Tex t .
            > >
            > > thanks
            > >
            > > --
            > > Regads,
            > > Rochdi[/color]
            >
            >
            >[/color]

            Comment

            • Mike

              #7
              RE: Combobox

              Oh, don't worry I have set the Valuemember and its working Thanks
              --
              Regads,
              Rochdi


              "Dennis" wrote:
              [color=blue]
              > Your objects in the combo box are of type "System.Data.Da taRowView" whose
              > "ToString" method returns the object's type name. Also, the text placed
              > into the combo items will be whatever the object's "ToString" method returns
              > unless you are using binding. I believe that if you are binding the combo
              > box to a DataView object, you need to set the ValueMember and DisplayMember
              > properties of the combo box.
              >
              >
              > Dennis in Houston
              >
              >
              > "Mike" wrote:
              >[color=green]
              > > Oh, I forget the mention that the code is the
              > > ComboBox1_Selec tedIndexChanged event
              > > --
              > > Regads,
              > > Rochdi
              > >
              > >
              > > "Mike" wrote:
              > >[color=darkred]
              > > > Hi
              > > > I'm using this code to display the selected item in msgbox
              > > > Dim ob As Object
              > > > ob = cmbCategory.Sel ectedItem
              > > > MsgBox(ob.ToStr ing())
              > > > but all what I see is "System.Data.Da taRowView", and the same result with
              > > > cmbCategory.Tex t .
              > > >
              > > > thanks
              > > >
              > > > --
              > > > Regads,
              > > > Rochdi[/color][/color][/color]

              Comment

              Working...