locked
I cant read the selected value of a comBoBox RRS feed

  • Question

  • Hi,

    I have a combobox, the values of the combobox are loaded from a BindingTableAdapter, the code is the following:

    Private Sub CenterComboBox_DropDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CenterComboBox.DropDown
    
      If CenterComboBox.Items.Count = 0 Then
    
    
        CenterComboBox.DisplayMember = "IDCenter"
    
    
        CenterComboBox.ValueMember = "IDCenter"
    
    
        CenterComboBox.DataSource = Me.CuadroMandosTableAdapter.GetDataByIdCentroMando()
    
    
     End If
    
    
     End Sub

    The values appear in the comboBox, and I select a value from it, but  the problem is that when I try to do CenterComboBox.SelectedValue(), it says me that CenterComboBox.SelectedValue()  is Nothing instead 1.

     

    I think that the problem is ubicated, in the code I have put it above. But I dont know what I have done wrong.  Maybe have I to iterate over the values of the GetData instead of assign directly to CenterComboBox.DataSource? I dont know......... but I am desperate.

     

    I would be very grateful if someone could help me to solve this question.

    Regards

    Tuesday, May 4, 2010 9:24 AM

Answers

  • Not such a fine place to set that combobox, can you try it in the Forms Load event.

    (Doublce Click somewhere on the form than you get it)

    While to get the value you can use the event which shows up when you double click your combobox. (selected index change)

     


    Success
    Cor
    • Marked as answer by iker garcia Tuesday, May 4, 2010 11:25 AM
    Tuesday, May 4, 2010 10:43 AM

All replies

  • Not such a fine place to set that combobox, can you try it in the Forms Load event.

    (Doublce Click somewhere on the form than you get it)

    While to get the value you can use the event which shows up when you double click your combobox. (selected index change)

     


    Success
    Cor
    • Marked as answer by iker garcia Tuesday, May 4, 2010 11:25 AM
    Tuesday, May 4, 2010 10:43 AM
  • Hi cor,

     

    I have solved the issue using the selectedValueChanged event

     

    Thanks for your help

    Tuesday, May 4, 2010 11:25 AM