Results 1 to 3 of 3

Thread: [2005] ComboBox & DataBinding

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    [2005] ComboBox & DataBinding

    Hi guys,

    I have a combobox which when the user selects the value, the two text boxes will display the value. It works nice and great, but the user wants it so that when the form loads, that the values are not displayed until the user selects there value from the combobox.

    Code:
            cboCaseFileProblemCode.DataSource = dataTable
            cboCaseFileProblemCode.DisplayMember = "Description"
            cboCaseFileProblemCode.ValueMember = "ProblemCode"
    
            If txtCaseFileProblemCode.DataBindings.Count > 0 Then
                txtCaseFileProblemCode.DataBindings.RemoveAt(0)
            End If
    
            If txtCaseFileProblemCategory.DataBindings.Count > 0 Then
                txtCaseFileProblemCategory.DataBindings.RemoveAt(0)
            End If
    
            txtCaseFileProblemCode.DataBindings.Add("TEXT", dataTable, "ProblemCode")
            txtCaseFileProblemCategory.DataBindings.Add("TEXT", dataTable, "CategoryName")
    
            cboCaseFileProblemCode.SelectedIndex = -1
    Here is what I am attempting to do

    Code:
            cboCaseFileProblemCode.SelectedIndex = -1
            txtCaseFileProblemCode.Clear()
            txtCaseFileProblemCategory.Clear()
    What happens is the combo box is empty, and also the textboxes, but when I select the first item, the two textboxes do no put the values in. But if I select anything other than that It shows the values. Is there a way I can sort this out?

    Thank you in advance..
    Last edited by TURKINATOR; Jul 9th, 2008 at 10:07 AM.
    Rate me if my response helped you. If not, I accept charity Rates as well.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    Re: [2005] ComboBox & DataBinding

    Sorry for being impatient, just need this item out of the way very soonish.
    Rate me if my response helped you. If not, I accept charity Rates as well.

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] ComboBox & DataBinding

    After you fill your datatable, you insert a blank row to it at index 0, Then call datatable.AcceptChanges (so later you don't accidentally insert a blank row to your database if you update the the data from your datatable). Now hadle the combobox.selectedindexchanged event, and test if the selected index = 0 (that is the 1st blank row in your datatable), you disable the textboxes so that the user can't make changes to that row (thus changing the rowstate to modified).
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

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