locked
Select combo by Value and put DisplayName in a textbox RRS feed

  • Question

  • Is it possible to put the DisplayName returned by a combobox selection in a separate textbox? 

    This worked pretty slick using WPF (after much hair-pulling) and I'm wondering if the same functionality is available in Lightswitch.

    I would like the DisplayName returned by a combobox selection to be displayed in a textbox next to that combobox.  Here is a screen-shot of how it worked in WPF:

    The source for the WPF combo is a lookup table, consisting of 2 columns:  Code and Description.  Each Code has it's own Description.  Using Lightswitch terminology, the code "D0000" is the Value, and the description "testing this procedure test123" is the DisplayName.  Back in WPF, "D0000" is selected from the combobox and "testing this procedure test123" automatically displays in the textbox. 

    Can I do the same thing in Lightswitch and if so, a code sample or link would be appreciated.


    Thanks.

    Wednesday, January 15, 2014 8:25 PM

Answers

  • Hello

    This should be fairly simple (unless I am misreading something!) especially as the values you want are in a table already. I'm explaining in V1 terms but should translate easy enough

    Firstly, on your screen designer select Add Data Item... and select the Local Property radio button and then select your table. In the Name field give it a meaningful name (i have called it Property1)

    Next drag your new property (Property1) from the left hand side onto the design area of the screen. This should now show Property1 as an autocompletebox. You will then have to go back up to Add Data Item to add a string for your heading to show in (call this PropertyHead)

    Next Select Property1 from the left hand side and click on the small arrow to the right of the Write Code button at the top right of the screen and select the Property1_Changed option. Then in the code window enter the following...

    this.PropertyHead = Property1.Value.ToString();

    Of course, you will have to replace Value with whatever the name of the Description is.

    HTH


    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)

    • Proposed as answer by Otis Ranger Friday, January 17, 2014 5:10 PM
    • Marked as answer by db_dweeb Friday, January 17, 2014 7:30 PM
    Friday, January 17, 2014 5:10 PM

All replies

  • Maybe I have my wording backwards.  DisplayName shows what was selected in the combobox already.  So it would be Value that I want to display in the textbox.

    D0000 could be changed to be the DisplayName, then "testing this procedure test123" could be the Value. 


    Thanks.

    Thursday, January 16, 2014 10:17 PM
  • Hello

    This should be fairly simple (unless I am misreading something!) especially as the values you want are in a table already. I'm explaining in V1 terms but should translate easy enough

    Firstly, on your screen designer select Add Data Item... and select the Local Property radio button and then select your table. In the Name field give it a meaningful name (i have called it Property1)

    Next drag your new property (Property1) from the left hand side onto the design area of the screen. This should now show Property1 as an autocompletebox. You will then have to go back up to Add Data Item to add a string for your heading to show in (call this PropertyHead)

    Next Select Property1 from the left hand side and click on the small arrow to the right of the Write Code button at the top right of the screen and select the Property1_Changed option. Then in the code window enter the following...

    this.PropertyHead = Property1.Value.ToString();

    Of course, you will have to replace Value with whatever the name of the Description is.

    HTH


    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)

    • Proposed as answer by Otis Ranger Friday, January 17, 2014 5:10 PM
    • Marked as answer by db_dweeb Friday, January 17, 2014 7:30 PM
    Friday, January 17, 2014 5:10 PM
  • Thanks, that worked great.

    Thanks.

    Friday, January 17, 2014 7:30 PM