Results 1 to 3 of 3

Thread: textbox value

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007

    textbox value

    In my wpf application, there is a listbox a several textboxes.
    On clicking an item in the listbox, the textboxes are populated accordingly.
    Do you know why the following happens?
    select an item in the listbox.
    textboxes are populated with other fields for the selected item. Let's say textbox1 has an empty value.
    Type "hello" in the textbox.
    select another item from the listbox.
    Now in the listbox, select the original item you selected. the textbox has the value "hello".
    If application is closed and re-opened then obviously the word "hello" is not there.
    Do you see why the value is retained eventhough the data is not saved into the database?

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002

    Re: textbox value

    Maybe because there is no update statement/command?
    VB6 & C# (WCF LINQ) mostly

    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Suffolk, UK

    Re: textbox value

    Because a TextBox binding defaults to TwoWay, meaning any changes you make in the TextBox get pushed back to the bound property. You have two choices if you don't want that behaviour. Firstly, specify a Mode of OneWay on the Binding. Secondly, use a TextBlock or Label which default to OneWay and don't have editing capabilities (it would seem odd to have an editable TextBox that doesn't save any changes you make)

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.