Results 1 to 10 of 10

Thread: Get Selected item in combox ??[Resolved]

  1. #1

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

    Get Selected item in combox ??[Resolved]

    Am I losing my mind ??
    I tried this but it sends me error :

    MsgBox(ComboBox4.SelectedItem)

    any thoughts plz ?
    Last edited by Pirate; Mar 3rd, 2003 at 03:14 AM.

  2. #2

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    the error says :
    Can't be converted to 'String' ?? I tried Ctype fun and ToString but with this stupid error ?

    I've just tried this but gives empy msgbox :

    MsgBox(ComboBox4.SelectedText.ToString)
    or
    MsgBox(ComboBox4.SelectedText)

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What type is the objects you are putting in the ComboBox? What do you have set as the DisplayMember of the Combo?

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Edneeis
    What type is the objects you are putting in the ComboBox? What do you have set as the DisplayMember of the Combo?
    I'm using this sub to load all tables in my db (your sub actually )

    VB Code:
    1. Public Shared Sub LoadTables(ByVal Combox As ComboBox)
    2.             Dim var As New Variables()
    3.             var.MyConnection.Open()
    4.             Dim Tables As DataTable = var.MyConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
    5.             var.MyConnection.Close()
    6.             Combox.DataSource = Tables
    7.             Combox.DisplayMember = "TABLE_NAME"
    8.         End Sub

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    and this line in the form_load .
    VB Code:
    1. ComboBox4.DropDownStyle = ComboBoxStyle.DropDownList

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    That is wierd must be some kind of conversation problem. Try just using Combox.Text, since if the item is selected the it is the same as what selectedtext should be.

  7. #7

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    lol . It's working now Edneeis ! thank you so much .
    I've tried everything except this .

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Weird .. I can get selected items in other comboxes .I think if it is bounded , then it needs more code or whatever .But can you guess what's going wrong ??

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No I'm not sure what the trouble is. I know even bound, you can usually get the SelectedText, but something about binding to a datatable directly or at least this one makes it not work.

    Actually I thought I've used it before with a bound combo, but maybe not because it did the same thing when bound to an array of strings.

  10. #10

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It's a bug maybe .Thanx anyways for the help !

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