Refresh Combo Box
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Refresh Combo Box

  1. #1
    Join Date
    Feb 2009
    Posts
    190

    Refresh Combo Box

    Hi,

    At button click on my form I have the code;

    Code:
    Private Sub BtnChk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnChk.Click
    
    
            Me.TblTruckTypeTableAdapter.Fill(Me.TruckTyp.TblTruckType)
            CmbTruckTyp.SelectedItem = CmbTruckTyp.FindStringExact(TxtTruckTyp.Text)
    
    
        End Sub

    And the combo box at selectedindex change;


    Code:
    Private Sub CmbTruckTyp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbTruckTyp.SelectedIndexChanged
    
    
            TxtTruckTyp.Text = CmbTruckTyp.Text
    
    End sub
    So what I am trying to do is when the button is clicked the combobox (CmbTruckTyp) is refreshed, then at the same time the previous selected item is focussed. This should be achieved by reading the value on the textbox (TxtTruckTyp.Text).

    Now, the problem is when I click the button, the textbox becomes BLANK and the combobox refreshes without selected the previous selecteditem.

    When testing;

    Code:
    Me.TblTruckTypeTableAdapter.Fill(Me.TruckTyp.TblTruckType)
    makes the TxtTruckTyp.Text to be empty. Why? Shouldn't this line of code ONLY update the combobox dropdownlist?

    Thanks

  2. #2
    Join Date
    Sep 2012
    Posts
    6

    Re: Refresh Combo Box

    try remember previous selected item in another variable, then check.
    As far i know, CmbTruckTyp.SelectedItem raises cmbtruck.indexchanged event,maybe that is the problem.
    can combobox.update change selecteditem???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center