none
Select a ComboBox value based on text the user types visual studio 10 RRS feed

  • Question

  • Hi

    Rather than using the value in the drop down list on a ComboBox i want to type the value in.

    When i use the drop down value it works fine

    But when I type in the same value it throws up an exception

    I have tried a couple of different codes but to no avail

    any help would be appreciated

    Ron


    ron

    Friday, March 16, 2012 5:00 PM

Answers

All replies

  • Hi Alisha

    I'm struggling a bit with that link

    I'm using Visual Studio 10

    I've populated the Combobox using data bound items as-:

    Data Source              SerialNoLookupDataSet

    Display Member         Serial_No

    Value Member           SerialNoID

    Selected Value          DispatchBindingSource - SerialNoID

    Its the Serial_No I want to type in rather than using the dropdown list

    Regards

    Ron


    ron

    Friday, March 16, 2012 7:50 PM
  • If you want to grabe user typed(inserted by user) value then you have to use

    Combobox1.Text

    If you write Combobox1.SelectedValue then it doesnt work.

    Combobox1.SelectedValue only work when you bind data to your combobox1.

    Hope you are clear.


    Hasibul Haque,MCC,MCPD hasibulhaque.com

    Sunday, March 18, 2012 10:53 AM
  • Please could you give me a hand I've been at this for ages, 

    My latest try was 

    Private Sub DispatchBindingNavigatorSaveItem_Click_3(sender As System.Object, e As System.EventArgs) Handles DispatchBindingNavigatorSaveItem.Click

            Dim Ex = ComboBox1.Text
            Dim str(0) As String
            str(0) = If(Ex Is Nothing, ComboBox1.Text, Ex.ToString)
            Me.Validate()
            Me.DispatchBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.DispatchInputDataSet)

    But obviously wrong

    Any help would be greatly appreciated.

    Ron


    ron

    Sunday, March 18, 2012 4:36 PM
  • What is the meaning of   str(0)

    Consider your syntext If(Ex Is Nothing, ComboBox1.Text, Ex.ToString) here ComboBox1.Text and Ex.ToString both are same so why you are using if condition?

    I am not clear from your code. actually what u want to do?


    Hasibul Haque,MCC,MCPD hasibulhaque.com

    Monday, March 19, 2012 8:04 AM
  • Thanks for getting back to me,

    I am afraid that I am still very much in the learning stage, all I'm trying to do is write some code witch lets me type in the ComboBox

    rather than use the drop down list, reason being this list will be to long to use.

    I have a Table called Dispatch within this table I have a column with the Table  SerialNoID

    The Table SerialNo has a column Serial_no.

    The form I am trying to create is for dispatch where they would know the serial number prior to filling out this form.

    So I have created a ComboBox for the SerialNo witch has a drop down list for the Serial_No.

    With only a short list of numbers this works great, but when you get a load of numbers not so great.

    So I want to be able to type the number in rather than use the lookup.

    I hope i have explained myself, as i said I;m still a bit green at this.

    Regards

    Ron


    ron

    Monday, March 19, 2012 8:27 PM
  • now clear. Have you solved your problem?

    Hasibul Haque,MCC,MCPD hasibulhaque.com

    Tuesday, March 20, 2012 3:03 AM
  • No I'm afraid I'm well and truly stuck.

    Regards

    Ron


    ron

    Tuesday, March 20, 2012 6:42 AM
  • i have uploaded a sample project (WindowsApplication1)for you and waiting for your feedback

    https://skydrive.live.com/redir.aspx?cid=6adaf076fdb92d9f&resid=6ADAF076FDB92D9F!266&parid=6ADAF076FDB92D9F!246&authkey=!ALYEKN8ON43sLDg


    Hasibul Haque,MCC,MCPD hasibulhaque.com

    • Marked as answer by ronthebore1 Thursday, April 5, 2012 8:18 PM
    Tuesday, March 20, 2012 7:50 AM
  • Thanks All Sorted

    ron

    Thursday, April 5, 2012 8:18 PM