Results 1 to 13 of 13

Thread: ListBox1.SelectedItem ??

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    ListBox1.SelectedItem ??

    I admit it that this bug is getting me crazy !!aaah . I've been using it this way all the way long but today I don't understand what's wrong (no bindings at all) ! It shows me this value as msgbox :

    System.Data.DataRowView

    I always use this way !
    MsgBox(ListBox1.SelectedItem.ToString)

    Can anyone figure out what's up !

  2. #2
    Member
    Join Date
    Jan 2003
    Location
    Beer City
    Posts
    33
    Hi,
    i have seen that problem too... it is in the databinding....but I do not remember what i did to fix it. i think i remember that you had to in source associate only with the dataset then in the datamember associate with the ttable and the column...

    but I have been frustrated with it too.

    anyone know exactly why it does this?

    Tal McMahon
    its called the "F1" key-- use it

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I hate this word "DataBinding" so I would never use it !

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Whether you bound the control or just filled the the items collection, you put a DataView or Rows in there and that is what they return from a ToString call. Try using SelectedText instead or setting the Displaymember property to one of the field names.

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It doesn't make any difference . I did that and went further to get selecteditem based on selectedindex with no luck . This is the first time I get such error . btw , I'm having this listbox in a panel , Do you think (well I don't...lol ) it's causing problems ?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What didn't make a difference? The displaymember? Or SelectedText?

    Also post your offending code as well as the code you are using to fill the listbox.

  7. #7
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    maybe....this.....

    I think you couldn't get the text which selected in the listbox, am I correct? If YES....
    Maybe you can try this code...
    VB Code:
    1. msgbox(ListBox1.GetItemText(ListBox1.SelectedItem))

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I'm using the same code which was taken from another working project . The function is correct I'm quite sure . I checked every line to see if there is something wrong but still can't get it to work . It's kind of weird bug . I'll wait till I buy this VS.NET2003 and finish my project agains 1.1 version . thanx thought for your reply !

  9. #9

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: maybe....this.....

    Originally posted by chinhow
    I think you couldn't get the text which selected in the listbox, am I correct? If YES....
    Maybe you can try this code...
    VB Code:
    1. msgbox(ListBox1.GetItemText(ListBox1.SelectedItem))
    Same error !

  10. #10
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    post your code where you put the data in the listview
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  11. #11

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    There is no listview . I used Listbox .

  12. #12
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    ok listbox then......
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  13. #13

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

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