Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Binding Source Issue

Binding Source Issue

Scheduled Pinned Locked Moved C#
helpcsharpdatabasewpfwinforms
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spankyleo123
    wrote on last edited by
    #1

    Hi, Am developing a winforms app using C#. I am using binding source to design the forms. I have a combobox with items "Yes" and "No" depending on the selection of this I enable or disable a text box.

    private void MyComboBox_TextChanged(object sender, EventArgs e)
    {
    if(MyComboBox.Text == "Yes")
    {
    textBox1.Enabled = true;
    }
    else
    {
    textox1.Text = ""; //am setting the text box to null if there is any text in it.
    textbox1.Enabled = false;
    }
    }

    Lets say I have selected "Yes" from the combobox and entered text into the textbox1 and save the input on save_click. the value gets stored into the database. Now if I go back to the form and edit it....I now change the combox to "NO". It clears the text in the textbox1 to "". When i click on save...it saves the record. But the problem is that it is not updating it into the database.? Any idea why this is happening or do i need to include more code into the event. Help Appreciated..thanks,

    E 1 Reply Last reply
    0
    • S spankyleo123

      Hi, Am developing a winforms app using C#. I am using binding source to design the forms. I have a combobox with items "Yes" and "No" depending on the selection of this I enable or disable a text box.

      private void MyComboBox_TextChanged(object sender, EventArgs e)
      {
      if(MyComboBox.Text == "Yes")
      {
      textBox1.Enabled = true;
      }
      else
      {
      textox1.Text = ""; //am setting the text box to null if there is any text in it.
      textbox1.Enabled = false;
      }
      }

      Lets say I have selected "Yes" from the combobox and entered text into the textbox1 and save the input on save_click. the value gets stored into the database. Now if I go back to the form and edit it....I now change the combox to "NO". It clears the text in the textbox1 to "". When i click on save...it saves the record. But the problem is that it is not updating it into the database.? Any idea why this is happening or do i need to include more code into the event. Help Appreciated..thanks,

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      You should be using the selected item changed event and not the Text Changed event. Also change your combo box to be of type DropDownList.

      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

      S 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        You should be using the selected item changed event and not the Text Changed event. Also change your combo box to be of type DropDownList.

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

        S Offline
        S Offline
        spankyleo123
        wrote on last edited by
        #3

        Can you tell me how to update the database when the binding source is modified please? In this case the textBox text is being modified and I want to know how the selected item changed (i think ur trying to say SelectedIndexChanged event ?) and changing the property of the combobox to dropdownlist would solve this issue? Thanks,

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups